AWS Lambda component
The
aws2-lambdacomponent invokes AWS Lambda functions and manages functions, versions, aliases, tags and event source mappings.
Scheme: aws2-lambda: · Crate: cameleer-cloud · Cargo feature: cloud · Consumer: no · Producer: yes ·
Apache Camel: AWS Lambda
When to use it
- Call serverless business logic from a route and continue with its result.
- Offload heavy work (image resizing, PDF rendering, model inference) from an edge device to Lambda.
- Expose a Lambda function to an AI agent as a tool behind a queue or an HTTP route.
- Deploy or update functions from a CI route (
createFunction,updateFunction,publishVersion).
URI format
aws2-lambda://functionNameOrArn[?options]Example
Invoke a function for each message of a queue and send its response to another queue:
- route:
id: resize-images
from:
uri: "aws2-sqs://images-to-resize?region={{env:AWS_REGION:us-east-1}}"
steps:
- to: "aws2-lambda://resize-image?region={{env:AWS_REGION:us-east-1}}&operation=invokeFunction"
- to: "aws2-sqs://resized-images?region={{env:AWS_REGION:us-east-1}}&autoCreateQueue=true"The body is sent as the payload; the response payload becomes the body. When the function fails,
the CamelAwsLambdaFunctionError header is set and the body holds the error document.
Rust DSL
ctx.add_routes(|b| {
b.from("aws2-sqs://images-to-resize?region={{env:AWS_REGION:us-east-1}}")
.to("aws2-lambda://resize-image?region={{env:AWS_REGION:us-east-1}}&operation=invokeFunction")
.to("aws2-sqs://resized-images?region={{env:AWS_REGION:us-east-1}}&autoCreateQueue=true");
})?;Options
Common AWS options (region, credentials, endpoint override, proxy) are listed in Cloud credentials.
| option | default | description |
|---|---|---|
operation | invokeFunction | invokeFunction, listFunctions, getFunction, deleteFunction, createFunction, updateFunction, createEventSourceMapping, deleteEventSourceMapping, listEventSourceMapping, listTags, tagResource, untagResource, publishVersion, listVersions, createAlias, deleteAlias, getAlias, listAliases. The CamelAwsLambdaOperation header overrides it. |
Every operation except invokeFunction sets the response document (a map, or a list for the list
operations) as the body.
Message headers
| header | direction | description |
|---|---|---|
CamelAwsLambdaOperation | in | Overrides operation. |
CamelAwsLambdaInvocationType | in | RequestResponse (default), Event (asynchronous) or DryRun. |
CamelAwsLambdaFunctionError | out | Set when the function returned an error. |
CamelAwsLambdaStatusCode | out | HTTP status of the invocation. |
CamelAwsLambdaS3Bucket, CamelAwsLambdaS3Key, CamelAwsLambdaS3ObjectVersion | in | Code location of createFunction / updateFunction (otherwise the body is the zip). |
CamelAwsLambdaRole, CamelAwsLambdaRuntime, CamelAwsLambdaHandler, CamelAwsLambdaDescription, CamelAwsLambdaTargetArn, CamelAwsLambdaMemorySize, CamelAwsLambdaKMSKeyArn, CamelAwsLambdaPublish, CamelAwsLambdaTimeout, CamelAwsLambdaTracingConfig, CamelAwsLambdaEnvironmentVariables, CamelAwsLambdaTags, CamelAwsLambdaSecurityGroupIds, CamelAwsLambdaSubnetIds | in | Function settings of createFunction. |
CamelAwsLambdaEventSourceArn, CamelAwsLambdaEventSourceBatchSize, CamelAwsLambdaEventSourceUuid, CamelAwsLambdaEventSourceStartingPosition | in | Event source mappings (StartingPosition is a Cameleer extension). |
CamelAwsLambdaResourceArn, CamelAwsLambdaResourceTags, CamelAwsLambdaResourceTagKeys | in | Tag operations. |
CamelAwsLambdaVersionDescription, CamelAwsLambdaFunctionVersion, CamelAwsLambdaAliasFunctionName, CamelAwsLambdaAliasFunctionDescription | in | Versions and aliases. |
Run it with Docker
docker run --rm -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
-v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/resize.camel.yamlCommon questions
How do I invoke a function asynchronously?
Set the header CamelAwsLambdaInvocationType to Event. Lambda queues the event and returns at once.
How do I call a specific version or alias?
Use the qualified ARN as the path, for example aws2-lambda://arn:aws:lambda:eu-west-1:123456789012:function:resize-image:prod.
How does the route know the function failed?
A function error does not throw: check ${header.CamelAwsLambdaFunctionError} (for example in a
choice) and read the error document from the body.
Related
- AWS SQS, AWS Step Functions, AWS EventBridge
- Azure Functions
- Cloud credentials
- Apache Camel AWS Lambda
Found a problem?
If something on this page doesn't match what Cameleer does, or you hit a bug while building
with it, please help fix it, whether you are a person or a coding agent:
open an issue that describes what you saw,
then fork the repository, fix it, add or update a test, run cargo test --workspace, and open
a pull request. CONTRIBUTING.md
explains the ground rules.