AWS Lambda
Since Camel 3.2
Only producer is supported
The AWS2 Lambda component supports create, get, list, delete, and invoke AWS Lambda functions.
Prerequisites
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Lambda. More information is available at AWS Lambda.
When creating a Lambda function, you need to specify an IAM role which has at least the AWSLambdaBasicExecuteRole policy attached.
URI Format
aws2-lambda://functionName[?options]
You can append query options to the URI in the following format:
?options=value&option2=value&…
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The AWS Lambda component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
Component configuration. | Lambda2Configuration | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The operation to perform. See the list of available operations in the component documentation. Enum values:
| invokeFunction | Lambda2Operations | |
Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option. | false | boolean | |
If we want to use a POJO request as body or not. | false | boolean | |
The region in which the Lambda client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example, ap-east-1) You’ll need to use the name Region.EU_WEST_1.id(). Enum values:
| String | ||
Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option. | String | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
Autowired To use an existing configured AwsLambdaClient client. | LambdaClient | ||
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean | |
To define a proxy host when instantiating the Lambda client. | String | ||
To define a proxy port when instantiating the Lambda client. | Integer | ||
To define a proxy protocol when instantiating the Lambda client. Enum values:
| HTTPS | Protocol | |
Amazon AWS Access Key. | String | ||
If using a profile credentials provider, this parameter will set the profile name. | String | ||
Amazon AWS Secret Key. | String | ||
Amazon AWS Session Token used when the user needs to assume an IAM role. | String | ||
If we want to trust all certificates in case of overriding the endpoint. | false | boolean | |
Set whether the Lambda client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean | |
Set whether the Lambda client should expect to load credentials through a profile credentials provider. | false | boolean | |
Set whether the Lambda client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Lambda. | false | boolean |
Endpoint Options
The AWS Lambda endpoint is configured using URI syntax:
aws2-lambda:function
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The operation to perform. See the list of available operations in the component documentation. Enum values:
| invokeFunction | Lambda2Operations | |
Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option. | false | boolean | |
If we want to use a POJO request as body or not. | false | boolean | |
The region in which the Lambda client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example, ap-east-1) You’ll need to use the name Region.EU_WEST_1.id(). Enum values:
| String | ||
Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option. | String | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Autowired To use an existing configured AwsLambdaClient client. | LambdaClient | ||
To define a proxy host when instantiating the Lambda client. | String | ||
To define a proxy port when instantiating the Lambda client. | Integer | ||
To define a proxy protocol when instantiating the Lambda client. Enum values:
| HTTPS | Protocol | |
Amazon AWS Access Key. | String | ||
If using a profile credentials provider, this parameter will set the profile name. | String | ||
Amazon AWS Secret Key. | String | ||
Amazon AWS Session Token used when the user needs to assume an IAM role. | String | ||
If we want to trust all certificates in case of overriding the endpoint. | false | boolean | |
Set whether the Lambda client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean | |
Set whether the Lambda client should expect to load credentials through a profile credentials provider. | false | boolean | |
Set whether the Lambda client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Lambda. | false | boolean |
Message Headers
The AWS Lambda component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
| Constant: | Required The operation we want to perform. Override operation passed as query parameter. | String | |
CamelAwsLambdaS3Bucket (createFunction) Constant: | Amazon S3 bucket name where the .zip file containing your deployment package is stored. This bucket must reside in the same AWS region where you are creating the Lambda function. | String | |
CamelAwsLambdaS3Key (createFunction) Constant: | The Amazon S3 object (the deployment package) key name you want to upload. | String | |
CamelAwsLambdaS3ObjectVersion (createFunction) Constant: | The Amazon S3 object (the deployment package) version you want to upload. | String | |
CamelAwsLambdaZipFile (createFunction) Constant: | The local path of the zip file (the deployment package). Without this header and the S3 headers, the message body is the zip. | String | |
CamelAwsLambdaDescription (createFunction) Constant: | The user-provided description. | String | |
CamelAwsLambdaRole (createFunction) Constant: | Required The Amazon Resource Name (ARN) of the IAM role that Lambda assumes when it executes your function to access any other Amazon Web Services (AWS) resources. | String | |
CamelAwsLambdaRuntime (createFunction) Constant: | Required The runtime environment for the Lambda function you are uploading. (for example nodejs22.x, java21 or python3.13). | String | |
CamelAwsLambdaHandler (createFunction) Constant: | Required The function within your code that Lambda calls to begin execution. For Node.js, it is the module-name.export value in your function. For Java, it can be package.class-name::handler or package.class-name. | String | |
CamelAwsLambdaTargetArn (createFunction) Constant: | The parent object that contains the target ARN (Amazon Resource Name) of an Amazon SQS queue or Amazon SNS topic. | String | |
CamelAwsLambdaMemorySize (createFunction) Constant: | The memory size, in MB, you configured for the function. Must be a multiple of 64 MB. | Integer | |
CamelAwsLambdaKMSKeyArn (createFunction) Constant: | The Amazon Resource Name (ARN) of the KMS key used to encrypt your function’s environment variables. If not provided, AWS Lambda will use a default service key. | String | |
CamelAwsLambdaEnvironmentVariables (createFunction) Constant: | The key-value pairs that represent your environment’s configuration settings. | Map | |
CamelAwsLambdaPublish (createFunction updateFunction) Constant: | This boolean parameter can be used to request AWS Lambda to create the Lambda function and publish a version as an atomic operation. | Boolean | |
CamelAwsLambdaTimeout (createFunction) Constant: | The function execution time at which Lambda should terminate the function. The default is 3 seconds. | Integer | |
CamelAwsLambdaTags (createFunction) Constant: | The list of tags (key-value pairs) assigned to the new function. | Map | |
CamelAwsLambdaTracingConfig (createFunction) Constant: | Your function’s tracing settings (Active or PassThrough). | String | |
CamelAwsLambdaSecurityGroupIds (createFunction) Constant: | If your Lambda function accesses resources in a VPC, a list of one or more security groups IDs in your VPC. | List | |
CamelAwsLambdaSubnetIds (createFunction) Constant: | If your Lambda function accesses resources in a VPC, a list of one or more subnet IDs in your VPC. | List | |
CamelAwsLambdaEventSourceArn (createEventSourceMapping) Constant: | The Amazon Resource Name (ARN) of the event source. | String | |
CamelAwsLambdaEventSourceBatchSize (createEventSourceMapping) Constant: | The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function. | Integer | |
CamelAwsLambdaEventSourceUuid (deleteEventSourceMapping) Constant: | The identifier of the event source mapping. | String | |
CamelAwsLambdaResourceArn (listTags tagResource untagResource) Constant: | The function’s Amazon Resource Name (ARN). | String | |
CamelAwsLambdaResourceTags (tagResource) Constant: | A list of tags to apply to the function. | Map | |
CamelAwsLambdaResourceTagKeys (untagResource) Constant: | A list of tag keys to remove from the function. | List | |
CamelAwsLambdaVersionDescription (publishVersion) Constant: | A description for the version to override the description in the function configuration. | String | |
CamelAwsLambdaVersionRevisionId (publishVersion) Constant: | Only update the function if the revision ID matches the ID that’s specified. | String | |
CamelAwsLambdaFunctionVersion (createAlias listAliases) Constant: | The function version to set in the alias. | String | |
CamelAwsLambdaAliasFunctionName (createAlias deleteAlias getAlias) Constant: | Required The function name of the alias. | String | |
CamelAwsLambdaAliasFunctionDescription (createAlias) Constant: | The function description to set in the alias. | String | |
CamelAwsLambdaMarker (listFunctions listVersions listAliases listEventSourceMapping listTags) Constant: | The marker for the next set of results. | String | |
CamelAwsLambdaMaxItems (listFunctions listVersions listAliases listEventSourceMapping) Constant: | The maximum number of results to return. | Integer | |
CamelAwsLambdaIsTruncated (listFunctions listVersions listAliases listEventSourceMapping) Constant: | Whether the response has more results (is truncated). | Boolean | |
CamelAwsLambdaFunctionArn (createFunction getFunction publishVersion createAlias getAlias) Constant: | The Amazon Resource Name (ARN) of the function. | String | |
CamelAwsLambdaStatusCode (invokeFunction) Constant: | The HTTP status code of the function invocation. | Integer | |
CamelAwsLambdaFunctionError (invokeFunction) Constant: | If present, indicates that an error occurred during function execution. The exchange does not fail: the body is the JSON of the error. | String | |
CamelAwsLambdaLogResult (invokeFunction) Constant: | The last 4 KB of the execution log. | String | |
CamelAwsLambdaFunctionUrlAuthType (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | Required The type of authentication that the function URL uses. Set to AWS_IAM to restrict access to authenticated users only. Set to NONE to bypass IAM authentication and allow any user to invoke the function. | String | |
CamelAwsLambdaFunctionUrlQualifier (createFunctionUrlConfig updateFunctionUrlConfig getFunctionUrlConfig deleteFunctionUrlConfig) Constant: | The alias name or $LATEST for the function URL. | String | |
CamelAwsLambdaFunctionUrlCorsAllowCredentials (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The cross-origin resource sharing (CORS) settings for the function URL. | String | |
CamelAwsLambdaFunctionUrlCorsAllowOrigins (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The allowed origins for CORS. | List | |
CamelAwsLambdaFunctionUrlCorsAllowMethods (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The allowed HTTP methods for CORS. | List | |
CamelAwsLambdaFunctionUrlCorsAllowHeaders (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The allowed HTTP headers for CORS. | List | |
CamelAwsLambdaFunctionUrlCorsExposeHeaders (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The exposed headers for CORS. | List | |
CamelAwsLambdaFunctionUrlCorsMaxAge (createFunctionUrlConfig updateFunctionUrlConfig) Constant: | The max age in seconds for CORS. | Integer | |
CamelAwsLambdaFunctionUrl (createFunctionUrlConfig getFunctionUrlConfig) Constant: | The function URL endpoint. | String | |
CamelAwsLambdaFunctionMemorySize (updateFunctionConfiguration) Constant: | The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB. | Integer | |
CamelAwsLambdaFunctionTimeout (updateFunctionConfiguration) Constant: | The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds. The maximum allowed value is 900 seconds. | Integer | |
CamelAwsLambdaFunctionRuntime (updateFunctionConfiguration) Constant: | The new runtime environment for the function. | String | |
CamelAwsLambdaFunctionHandler (updateFunctionConfiguration) Constant: | The new function handler. | String | |
CamelAwsLambdaReservedConcurrentExecutions (putFunctionConcurrency) Constant: | Required The number of simultaneous executions to reserve for the function. | Integer | |
CamelAwsLambdaStatementId (addPermission) Constant: | Required A unique statement identifier for the permission. | String | |
CamelAwsLambdaAction (addPermission) Constant: | Required The action that the principal can use on the function. For example, lambda:InvokeFunction or lambda:GetFunction. | String | |
CamelAwsLambdaPrincipal (addPermission) Constant: | Required The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the function. For example, s3.amazonaws.com or 123456789012. | String | |
CamelAwsLambdaSourceAccount (addPermission) Constant: | The Amazon Web Services account ID of the principal. | String | |
CamelAwsLambdaSourceArn (addPermission) Constant: | The ARN of the Amazon Web Services resource that invokes the function. For example, an Amazon S3 bucket or Amazon SNS topic. | String |
Message Body
The message body at each side of the AWS Lambda component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| The payload of invokeFunction, the default, as JSON text: bytes and a stream are sent as they are, a file is read as text, a Map or a POJO is sent as its toString(), so marshal it first, and no body invokes the function without a payload. createFunction and updateFunction take the code from the CamelAwsLambdaZipFile header or the S3 headers, which win over the body, else the body is the zip of the code as bytes, a stream or a file, and a body that does not convert to bytes fails. The other operations take their input from headers, or with pojoRequest=true from the request of the AWS SDK in the body.
|
Producer output |
| The response of the AWS SDK for the operation, such as a ListFunctionsResponse. For invokeFunction, the default, the payload of the response as text: the JSON the function returns, or the JSON of its error with the CamelAwsLambdaFunctionError header set, as an error of the function does not fail the exchange.
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers are described in the Camel Catalog.
Required Lambda component options
You have to provide the awsLambdaClient in the Registry or your accessKey and secretKey to access the Amazon Lambda service.
Usage
Static credentials, Default Credential Provider and Profile Credentials Provider
You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.
The order of evaluation for Default Credentials Provider is the following:
-
Java system properties -
aws.accessKeyIdandaws.secretKey. -
Environment variables -
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY. -
Web Identity Token from AWS STS.
-
The shared credentials and config files.
-
Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable
AWS_CONTAINER_CREDENTIALS_RELATIVE_URIis set. -
Amazon EC2 Instance profile credentials.
You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.
Only one of static, default and profile credentials could be used at the same time.
For more information about this you can look at AWS credentials documentation
List of Available Operations
-
listFunctions
-
getFunction
-
createFunction
-
deleteFunction
-
invokeFunction
-
updateFunction
-
createEventSourceMapping
-
deleteEventSourceMapping
-
listEventSourceMapping
-
listTags
-
tagResource
-
untagResource
-
publishVersion
-
listVersions
-
createAlias
-
deleteAlias
-
getAlias
-
listAliases
-
createFunctionUrlConfig
-
getFunctionUrlConfig
-
updateFunctionUrlConfig
-
deleteFunctionUrlConfig
-
listFunctionUrlConfigs
-
getFunctionConfiguration
-
updateFunctionConfiguration
-
putFunctionConcurrency
-
deleteFunctionConcurrency
-
getFunctionConcurrency
-
addPermission
-
removePermission
-
getPolicy
Examples
Producer Example
To have a full understanding of how the component works, you may have a look at these integration tests
Producer Examples
-
CreateFunction: this operation will create a function for you in AWS Lambda
-
Java
-
XML
-
YAML
from("direct:createFunction")
.to("aws2-lambda://GetHelloWithName?operation=createFunction")
.to("mock:result"); <route>
<from uri="direct:createFunction"/>
<to uri="aws2-lambda://GetHelloWithName?operation=createFunction"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:createFunction
steps:
- to:
uri: aws2-lambda://GetHelloWithName
parameters:
operation: createFunction
- to:
uri: mock:result and by sending
template.send("direct:createFunction", ExchangePattern.InOut, exchange -> {
exchange.getIn().setHeader("CamelAwsLambdaRuntime", "nodejs22.x");
exchange.getIn().setHeader("CamelAwsLambdaHandler", "GetHelloWithName.handler");
exchange.getIn().setHeader("CamelAwsLambdaDescription", "Hello with node.js on Lambda");
exchange.getIn().setHeader("CamelAwsLambdaRole",
"arn:aws:iam::643534317684:role/lambda-execution-role");
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(
classLoader
.getResource("org/apache/camel/component/aws2/lambda/function/node/GetHelloWithName.zip")
.getFile());
exchange.getIn().setBody(new FileInputStream(file));
}); The code of the function is the zip file of the CamelAwsLambdaZipFile header, or the S3 location of the CamelAwsLambdaS3Bucket and CamelAwsLambdaS3Key headers (and optionally CamelAwsLambdaS3ObjectVersion). When neither is set, the message body is the zip, as bytes, a stream or a file. A body that does not convert to bytes fails the exchange, and text is sent as its bytes, which AWS rejects as not a zip. The updateFunction operation takes the code in the same way. The zip file header and the S3 headers cannot be used together, and the S3 location needs both the bucket and the key.
-
InvokeFunction: this operation invokes the function with the message body as the payload
The body is sent as the payload: a byte[] or a stream as it is, any other body as text in UTF-8. Without a body the function is invoked without a payload. The body of the reply is the payload the function returned, as a String.
An error of the function does not fail the exchange: the body is the JSON of the error that the function returned, and the CamelAwsLambdaFunctionError header is set (for example to Unhandled). Check this header, for example with a filter or a choice, to handle the error.
Function URL Operations
Function URLs provide a dedicated HTTP(S) endpoint for your Lambda function, enabling direct invocation via HTTP without needing API Gateway.
-
createFunctionUrlConfig: this operation will create a function URL for your Lambda function
-
Java
-
XML
-
YAML
from("direct:createFunctionUrl")
.setHeader("CamelAwsLambdaFunctionUrlAuthType", constant("NONE"))
.to("aws2-lambda://myFunction?operation=createFunctionUrlConfig")
.to("mock:result"); <route>
<from uri="direct:createFunctionUrl"/>
<setHeader name="CamelAwsLambdaFunctionUrlAuthType">
<constant>NONE</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=createFunctionUrlConfig"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:createFunctionUrl
steps:
- setHeader:
name: CamelAwsLambdaFunctionUrlAuthType
constant: NONE
- to:
uri: aws2-lambda://myFunction
parameters:
operation: createFunctionUrlConfig
- to:
uri: mock:result The FUNCTION_URL_AUTH_TYPE can be either NONE (public access) or AWS_IAM (authenticated access).
-
getFunctionUrlConfig: this operation will retrieve the function URL configuration
-
Java
-
XML
-
YAML
from("direct:getFunctionUrl")
.to("aws2-lambda://myFunction?operation=getFunctionUrlConfig")
.to("mock:result"); <route>
<from uri="direct:getFunctionUrl"/>
<to uri="aws2-lambda://myFunction?operation=getFunctionUrlConfig"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:getFunctionUrl
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: getFunctionUrlConfig
- to:
uri: mock:result -
updateFunctionUrlConfig: this operation will update the function URL configuration
-
Java
-
XML
-
YAML
from("direct:updateFunctionUrl")
.setHeader("CamelAwsLambdaFunctionUrlAuthType", constant("AWS_IAM"))
.to("aws2-lambda://myFunction?operation=updateFunctionUrlConfig")
.to("mock:result"); <route>
<from uri="direct:updateFunctionUrl"/>
<setHeader name="CamelAwsLambdaFunctionUrlAuthType">
<constant>AWS_IAM</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=updateFunctionUrlConfig"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:updateFunctionUrl
steps:
- setHeader:
name: CamelAwsLambdaFunctionUrlAuthType
constant: AWS_IAM
- to:
uri: aws2-lambda://myFunction
parameters:
operation: updateFunctionUrlConfig
- to:
uri: mock:result -
deleteFunctionUrlConfig: this operation will delete the function URL
-
Java
-
XML
-
YAML
from("direct:deleteFunctionUrl")
.to("aws2-lambda://myFunction?operation=deleteFunctionUrlConfig")
.to("mock:result"); <route>
<from uri="direct:deleteFunctionUrl"/>
<to uri="aws2-lambda://myFunction?operation=deleteFunctionUrlConfig"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:deleteFunctionUrl
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: deleteFunctionUrlConfig
- to:
uri: mock:result -
listFunctionUrlConfigs: this operation will list all function URLs for a function
-
Java
-
XML
-
YAML
from("direct:listFunctionUrls")
.to("aws2-lambda://myFunction?operation=listFunctionUrlConfigs")
.to("mock:result"); <route>
<from uri="direct:listFunctionUrls"/>
<to uri="aws2-lambda://myFunction?operation=listFunctionUrlConfigs"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:listFunctionUrls
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: listFunctionUrlConfigs
- to:
uri: mock:result Function Configuration Operations
Function Configuration operations allow you to view and modify your Lambda function’s runtime settings.
-
getFunctionConfiguration: this operation will retrieve the configuration details of a function
-
Java
-
XML
-
YAML
from("direct:getFunctionConfiguration")
.to("aws2-lambda://myFunction?operation=getFunctionConfiguration")
.to("mock:result"); <route>
<from uri="direct:getFunctionConfiguration"/>
<to uri="aws2-lambda://myFunction?operation=getFunctionConfiguration"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:getFunctionConfiguration
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: getFunctionConfiguration
- to:
uri: mock:result -
updateFunctionConfiguration: this operation will update the configuration of a function
-
Java
-
XML
-
YAML
from("direct:updateFunctionConfiguration")
.setHeader("CamelAwsLambdaFunctionMemorySize", constant(512))
.setHeader("CamelAwsLambdaFunctionTimeout", constant(60))
.setHeader("CamelAwsLambdaDescription", constant("Updated function description"))
.to("aws2-lambda://myFunction?operation=updateFunctionConfiguration")
.to("mock:result"); <route>
<from uri="direct:updateFunctionConfiguration"/>
<setHeader name="CamelAwsLambdaFunctionMemorySize">
<constant resultType="java.lang.Integer">512</constant>
</setHeader>
<setHeader name="CamelAwsLambdaFunctionTimeout">
<constant resultType="java.lang.Integer">60</constant>
</setHeader>
<setHeader name="CamelAwsLambdaDescription">
<constant>Updated function description</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=updateFunctionConfiguration"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:updateFunctionConfiguration
steps:
- setHeader:
name: CamelAwsLambdaFunctionMemorySize
constant: 512
- setHeader:
name: CamelAwsLambdaFunctionTimeout
constant: 60
- setHeader:
name: CamelAwsLambdaDescription
constant: Updated function description
- to:
uri: aws2-lambda://myFunction
parameters:
operation: updateFunctionConfiguration
- to:
uri: mock:result Concurrency Operations
Concurrency operations allow you to manage reserved concurrency for your Lambda functions.
-
putFunctionConcurrency: this operation will set the reserved concurrency for a function
-
Java
-
XML
-
YAML
from("direct:putFunctionConcurrency")
.setHeader("CamelAwsLambdaReservedConcurrentExecutions", constant(100))
.to("aws2-lambda://myFunction?operation=putFunctionConcurrency")
.to("mock:result"); <route>
<from uri="direct:putFunctionConcurrency"/>
<setHeader name="CamelAwsLambdaReservedConcurrentExecutions">
<constant>100</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=putFunctionConcurrency"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:putFunctionConcurrency
steps:
- setHeader:
name: CamelAwsLambdaReservedConcurrentExecutions
constant: "100"
- to:
uri: aws2-lambda://myFunction
parameters:
operation: putFunctionConcurrency
- to:
uri: mock:result -
deleteFunctionConcurrency: this operation will remove reserved concurrency from a function
-
Java
-
XML
-
YAML
from("direct:deleteFunctionConcurrency")
.to("aws2-lambda://myFunction?operation=deleteFunctionConcurrency")
.to("mock:result"); <route>
<from uri="direct:deleteFunctionConcurrency"/>
<to uri="aws2-lambda://myFunction?operation=deleteFunctionConcurrency"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:deleteFunctionConcurrency
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: deleteFunctionConcurrency
- to:
uri: mock:result -
getFunctionConcurrency: this operation will retrieve the reserved concurrency for a function
-
Java
-
XML
-
YAML
from("direct:getFunctionConcurrency")
.to("aws2-lambda://myFunction?operation=getFunctionConcurrency")
.to("mock:result"); <route>
<from uri="direct:getFunctionConcurrency"/>
<to uri="aws2-lambda://myFunction?operation=getFunctionConcurrency"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:getFunctionConcurrency
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: getFunctionConcurrency
- to:
uri: mock:result Permission Operations
Permission operations allow you to manage the resource-based policy for your Lambda functions.
-
addPermission: this operation will add a permission to the function’s resource-based policy
-
Java
-
XML
-
YAML
from("direct:addPermission")
.setHeader("CamelAwsLambdaStatementId", constant("s3-invoke"))
.setHeader("CamelAwsLambdaAction", constant("lambda:InvokeFunction"))
.setHeader("CamelAwsLambdaPrincipal", constant("s3.amazonaws.com"))
.setHeader("CamelAwsLambdaSourceArn", constant("arn:aws:s3:::my-bucket"))
.to("aws2-lambda://myFunction?operation=addPermission")
.to("mock:result"); <route>
<from uri="direct:addPermission"/>
<setHeader name="CamelAwsLambdaStatementId">
<constant>s3-invoke</constant>
</setHeader>
<setHeader name="CamelAwsLambdaAction">
<constant>lambda:InvokeFunction</constant>
</setHeader>
<setHeader name="CamelAwsLambdaPrincipal">
<constant>s3.amazonaws.com</constant>
</setHeader>
<setHeader name="CamelAwsLambdaSourceArn">
<constant>arn:aws:s3:::my-bucket</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=addPermission"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:addPermission
steps:
- setHeader:
name: CamelAwsLambdaStatementId
constant: s3-invoke
- setHeader:
name: CamelAwsLambdaAction
constant: "lambda:InvokeFunction"
- setHeader:
name: CamelAwsLambdaPrincipal
constant: s3.amazonaws.com
- setHeader:
name: CamelAwsLambdaSourceArn
constant: "arn:aws:s3:::my-bucket"
- to:
uri: aws2-lambda://myFunction
parameters:
operation: addPermission
- to:
uri: mock:result -
removePermission: this operation will remove a permission from the function’s resource-based policy
-
Java
-
XML
-
YAML
from("direct:removePermission")
.setHeader("CamelAwsLambdaStatementId", constant("s3-invoke"))
.to("aws2-lambda://myFunction?operation=removePermission")
.to("mock:result"); <route>
<from uri="direct:removePermission"/>
<setHeader name="CamelAwsLambdaStatementId">
<constant>s3-invoke</constant>
</setHeader>
<to uri="aws2-lambda://myFunction?operation=removePermission"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:removePermission
steps:
- setHeader:
name: CamelAwsLambdaStatementId
constant: s3-invoke
- to:
uri: aws2-lambda://myFunction
parameters:
operation: removePermission
- to:
uri: mock:result -
getPolicy: this operation will retrieve the resource-based policy for a function
-
Java
-
XML
-
YAML
from("direct:getPolicy")
.to("aws2-lambda://myFunction?operation=getPolicy")
.to("mock:result"); <route>
<from uri="direct:getPolicy"/>
<to uri="aws2-lambda://myFunction?operation=getPolicy"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:getPolicy
steps:
- to:
uri: aws2-lambda://myFunction
parameters:
operation: getPolicy
- to:
uri: mock:result You can also configure CORS settings for function URLs:
from("direct:createFunctionUrlWithCors")
.process(exchange -> {
exchange.getIn().setHeader("CamelAwsLambdaFunctionUrlAuthType", "NONE");
exchange.getIn().setHeader("CamelAwsLambdaFunctionUrlCorsAllowOrigins",
List.of("https://example.com"));
exchange.getIn().setHeader("CamelAwsLambdaFunctionUrlCorsAllowMethods",
List.of("GET", "POST"));
exchange.getIn().setHeader("CamelAwsLambdaFunctionUrlCorsAllowHeaders",
List.of("Content-Type", "Authorization"));
exchange.getIn().setHeader("CamelAwsLambdaFunctionUrlCorsMaxAge", 3600);
})
.to("aws2-lambda://myFunction?operation=createFunctionUrlConfig")
.to("mock:result"); Using a POJO as body
Sometimes building an AWS Request can be complex because of multiple options. We introduce the possibility to use a POJO as the body. In AWS Lambda there are multiple operations you can submit, as an example for Get Function request, you can do something like:
from("direct:getFunction")
.setBody(GetFunctionRequest.builder().functionName("test").build())
.to("aws2-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&operation=getFunction&pojoRequest=true") In this way, you’ll pass the request directly without the need of passing headers and options specifically related to this operation.
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws2-lambda</artifactId>
<version>${camel-version}</version>
</dependency> where ${camel-version} must be replaced by the actual version of Camel.