Skip to main content

AWS Lambda

Extend your agent's capabilities by triggering serverless functions via AWS Lambda.

This tool allows you to run background jobs, execute custom logic, or call remote functions hosted on AWS directly from your agent's workflow.

💡 Core Concepts

To successfully integrate AWS Lambda, understanding these two components is essential:

1. Function Name

The function_name is the specific identifier of the Lambda function you wish to invoke. It must exist in the AWS Region you specify.

2. Payload Structure

The payload is the data sent to your Lambda function by the agent. Data provided in the tool config (via YAML file) will be static.


⚙️ Configuration Steps

Follow these steps to configure the AWS Lambda tool for your agent.

Prepare AWS Credentials

Ensure you have the following credentials ready from your AWS IAM console:

  • AWS Access Key ID
  • AWS Secret Access Key
  • AWS Region (Default is us-east-1 if not specified)
info

For security, we recommend storing these credentials in the SVAHNAR Key Vault rather than hardcoding them in your configuration files.

Assign Tool & Function

In your agent's configuration, assign the AWS_Lambda tool and specify the target function.

tool_assigned:
- name: AWS_Lambda
config:
function_name: "process-user-data"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY}"
AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_KEY}"

Define Payload (Optional)

You can pass arguments to your Lambda function in two ways(via yaml file) instead of Agent sending them:

Method A: Direct Values Hardcode specific values directly into the YAML configuration.

payload: |-
payload:
action: "sync_users"
environment: "production"

Method B: Key Vault Variables Inject secure secrets dynamically using the ${Variable} syntax.

payload: |-
payload:
api_token: "${MySecureToken}"

tip

If you have a complex data in JSON format and need to convert it to YAML, check out our dedicated JSON to YAML Conversion Guide.


📚 Practical Recipes (Examples)

Recipe 1: Basic Invocation

Use Case: Triggering a simple background job with hardcoded parameters.

create_vertical_agent_network:
agent-1:
agent_name: lambda_runner
LLM_config:
params:
model: gpt-4o
tools:
tool_assigned:
- name: AWS_Lambda
config:
function_name: "process-user-data"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY}"
AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_KEY}"
agent_function:
- "Invoke the lambda function to process the user data." # user data will be sent by LLM
incoming_edge:
- Start
outgoing_edge: []

🚑 Troubleshooting

  • Missing required field: 'function_name'

    • Ensure function_name is correctly spelled and nested under config in your YAML.
  • YAML Parsing Errors

    • The payload block is sensitive to indentation. Ensure your keys (like payload:) start strictly 2 spaces from the newline.
    • Verify strings are enclosed in double quotes ".
  • Error invoking AWS Lambda function

    • Check that your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY have permission to invoke the specific Lambda function (lambda:InvokeFunction).
    • Verify the AWS_REGION matches where your function is deployed.