id
stringlengths 14
16
| text
stringlengths 1
2.43k
| source
stringlengths 99
229
|
|---|---|---|
582b9a75ec29-0
|
**SecurityGroupIds** <a name="SSS-Type-VpcConfig-SecurityGroupIds"></a>
A list of VPC security groups IDs\.
Type: Array of strings
Array Members: Maximum number of 5 items\.
Required: No
**SubnetIds** <a name="SSS-Type-VpcConfig-SubnetIds"></a>
A list of VPC subnet IDs\.
Type: Array of strings
Array Members: Maximum number of 16 items\.
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_VpcConfig.md
|
7e7ba1e3f08d-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/VpcConfig)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/VpcConfig)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/VpcConfig)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/VpcConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_VpcConfig.md
|
eafabf5c968a-0
|
You can configure your Lambda function to pull in additional code and content in the form of layers\. A layer is a ZIP archive that contains libraries, a [custom runtime](runtimes-custom.md), or other dependencies\. With layers, you can use libraries in your function without needing to include them in your deployment package\.
Layers let you keep your deployment package small, which makes development easier\. You can avoid errors that can occur when you install and package dependencies with your function code\. For Node\.js, Python, and Ruby functions, you can [develop your function code in the Lambda console](code-editor.md) as long as you keep your deployment package under 3 MB\.
**Note**
A function can use up to 5 layers at a time\. The total unzipped size of the function and all layers can't exceed the unzipped deployment package size limit of 250 MB\. For more information, see [AWS Lambda quotas](gettingstarted-limits.md)\.
You can create layers, or use layers published by AWS and other AWS customers\. Layers support [resource\-based policies](#configuration-layers-permissions) for granting layer usage permissions to specific AWS accounts, [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/), or all accounts\.
Layers are extracted to the `/opt` directory in the function execution environment\. Each runtime looks for libraries in a different location under `/opt`, depending on the language\. [Structure your layer](#configuration-layers-path) so that function code can access libraries without additional configuration\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
eafabf5c968a-1
|
You can also use AWS Serverless Application Model \(AWS SAM\) to manage layers and your function's layer configuration\. For instructions, see [Declaring serverless resources](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template.html) in the *AWS Serverless Application Model Developer Guide*\.
**Topics**
+ [Configuring a function to use layers](#configuration-layers-using)
+ [Managing layers](#configuration-layers-manage)
+ [Including library dependencies in a layer](#configuration-layers-path)
+ [Layer permissions](#configuration-layers-permissions)
+ [AWS CloudFormation and AWS SAM](#configuration-layers-cloudformation)
+ [Sample applications](#configuration-layers-samples)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
3c44f3936ca7-0
|
You can specify up to 5 layers in your function's configuration, during or after function creation\. You choose a specific version of a layer to use\. If you want to use a different version later, update your function's configuration\.
To add layers to your function, use the `update-function-configuration` command\. The following example adds two layers: one from the same account as the function, and one from a different account\.
```
$ aws lambda update-function-configuration --function-name my-function \
--layers arn:aws:lambda:us-east-2:123456789012:layer:my-layer:3 \
arn:aws:lambda:us-east-2:210987654321:layer:their-layer:2
{
"FunctionName": "test-layers",
"FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function",
"Runtime": "nodejs12.x",
"Role": "arn:aws:iam::123456789012:role/service-role/lambda-role",
"Layers": [
{
"Arn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:3",
"CodeSize": 169
},
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
3c44f3936ca7-1
|
"CodeSize": 169
},
{
"Arn": "arn:aws:lambda:us-east-2:210987654321:layer:their-layer:2",
"CodeSize": 169
}
],
"RevisionId": "81cc64f5-5772-449a-b63e-12330476bcc4",
...
}
```
You must specify the version of each layer to use by providing the full ARN of the layer version\. When you add layers to a function that already has layers, the previous list is overwritten by the new one\. Include all layers every time you update the layer configuration\. To remove all layers, specify an empty list\.
```
$ aws lambda update-function-configuration --function-name my-function --layers []
```
Your function can access the content of the layer during execution in the `/opt` directory\. Layers are applied in the order that's specified, merging any folders with the same name\. If the same file appears in multiple layers, the version in the last applied layer is used\.
The creator of a layer can delete the version of the layer that you're using\. When this happens, your function continues to run as though the layer version still existed\. However, when you update the layer configuration, you must remove the reference to the deleted version\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a619e5726323-0
|
To create a layer, use the `publish-layer-version` command with a name, description, ZIP archive, and a list of [runtimes](lambda-runtimes.md) that are compatible with the layer\. The list of runtimes is optional, but it makes the layer easier to discover\.
```
$ aws lambda publish-layer-version --layer-name my-layer --description "My layer" --license-info "MIT" \
--content S3Bucket=lambda-layers-us-east-2-123456789012,S3Key=layer.zip --compatible-runtimes python3.6 python3.7
{
"Content": {
"Location": "https://awslambda-us-east-2-layers.s3.us-east-2.amazonaws.com/snapshots/123456789012/my-layer-4aaa2fbb-ff77-4b0a-ad92-5b78a716a96a?versionId=27iWyA73cCAYqyH...",
"CodeSha256": "tv9jJO+rPbXUUXuRKi7CwHzKtLDkDRJLB3cC3Z/ouXo=",
"CodeSize": 169
},
"LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer",
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a619e5726323-1
|
"LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer",
"LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1",
"Description": "My layer",
"CreatedDate": "2018-11-14T23:03:52.894+0000",
"Version": 1,
"LicenseInfo": "MIT",
"CompatibleRuntimes": [
"python3.6",
"python3.7",
"python3.8"
]
}
```
Each time you call `publish-layer-version`, you create a new version\. Functions that use the layer refer directly to a layer version\. You can [configure permissions](#configuration-layers-permissions) on an existing layer version, but to make any other changes, you must create a new version\.
To find layers that are compatible with your function's runtime, use the `list-layers` command\.
```
$ aws lambda list-layers --compatible-runtime python3.8
{
"Layers": [
{
"LayerName": "my-layer",
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a619e5726323-2
|
{
"Layers": [
{
"LayerName": "my-layer",
"LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer",
"LatestMatchingVersion": {
"LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:2",
"Version": 2,
"Description": "My layer",
"CreatedDate": "2018-11-15T00:37:46.592+0000",
"CompatibleRuntimes": [
"python3.6",
"python3.7",
"python3.8",
]
}
}
]
}
```
You can omit the runtime option to list all layers\. The details in the response reflect the latest version of the layer\. See all the versions of a layer with `list-layer-versions`\. To see more information about a version, use `get-layer-version`\.
```
$ aws lambda get-layer-version --layer-name my-layer --version-number 2
{
"Content": {
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a619e5726323-3
|
$ aws lambda get-layer-version --layer-name my-layer --version-number 2
{
"Content": {
"Location": "https://awslambda-us-east-2-layers.s3.us-east-2.amazonaws.com/snapshots/123456789012/my-layer-91e9ea6e-492d-4100-97d5-a4388d442f3f?versionId=GmvPV.309OEpkfN...",
"CodeSha256": "tv9jJO+rPbXUUXuRKi7CwHzKtLDkDRJLB3cC3Z/ouXo=",
"CodeSize": 169
},
"LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer",
"LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:2",
"Description": "My layer",
"CreatedDate": "2018-11-15T00:37:46.592+0000",
"Version": 2,
"CompatibleRuntimes": [
"python3.6",
"python3.7",
"python3.8"
]
}
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a619e5726323-4
|
"python3.6",
"python3.7",
"python3.8"
]
}
```
The link in the response lets you download the layer archive and is valid for 10 minutes\. To delete a layer version, use the `delete-layer-version` command\.
```
$ aws lambda delete-layer-version --layer-name my-layer --version-number 1
```
When you delete a layer version, you can no longer configure functions to use it\. However, any function that already uses the version continues to have access to it\. Version numbers are never re\-used for a layer name\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
2c29a920b723-0
|
You can move runtime dependencies out of your function code by placing them in a layer\. Lambda runtimes include paths in the `/opt` directory to ensure that your function code has access to libraries that are included in layers\.
To include libraries in a layer, place them in one of the folders supported by your runtime, or modify that path variable for your language\.
+ **Node\.js** – `nodejs/node_modules`, `nodejs/node8/node_modules` \(`NODE_PATH`\)
**Example AWS X\-Ray SDK for Node\.js**
```
xray-sdk.zip
â”” nodejs/node_modules/aws-xray-sdk
```
+ **Python** – `python`, `python/lib/python3.8/site-packages` \(site directories\)
**Example Pillow**
```
pillow.zip
│ python/PIL
â”” python/Pillow-5.3.0.dist-info
```
+ **Ruby** – `ruby/gems/2.5.0` \(`GEM_PATH`\), `ruby/lib` \(`RUBYLIB`\)
**Example JSON**
```
json.zip
â”” ruby/gems/2.5.0/
| build_info
| cache
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
2c29a920b723-1
|
json.zip
â”” ruby/gems/2.5.0/
| build_info
| cache
| doc
| extensions
| gems
| â”” json-2.1.0
â”” specifications
â”” json-2.1.0.gemspec
```
+ **Java** – `java/lib` \(classpath\)
**Example Jackson**
```
jackson.zip
â”” java/lib/jackson-core-2.2.3.jar
```
+ **All** – `bin` \(`PATH`\), `lib` \(`LD_LIBRARY_PATH`\)
**Example JQ**
```
jq.zip
â”” bin/jq
```
For more information about path settings in the Lambda execution environment, see [Runtime environment variables](configuration-envvars.md#configuration-envvars-runtime)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a5acc4402c35-0
|
Layer usage permissions are managed on the resource\. To configure a function with a layer, you need permission to call `GetLayerVersion` on the layer version\. For functions in your account, you can get this permission from your [user policy](access-control-identity-based.md) or from the function's [resource\-based policy](access-control-resource-based.md)\. To use a layer in another account, you need permission on your user policy, and the owner of the other account must grant your account permission with a resource\-based policy\.
To grant layer\-usage permission to another account, add a statement to the layer version's permissions policy with the `add-layer-version-permission` command\. In each statement, you can grant permission to a single account, all accounts, or an organization\.
```
$ aws lambda add-layer-version-permission --layer-name xray-sdk-nodejs --statement-id xaccount \
--action lambda:GetLayerVersion --principal 210987654321 --version-number 1 --output text
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
a5acc4402c35-1
|
--action lambda:GetLayerVersion --principal 210987654321 --version-number 1 --output text
e210ffdc-e901-43b0-824b-5fcd0dd26d16 {"Sid":"xaccount","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::210987654321:root"},"Action":"lambda:GetLayerVersion","Resource":"arn:aws:lambda:us-east-2:123456789012:layer:xray-sdk-nodejs:1"}
```
Permissions only apply to a single version of a layer\. Repeat the procedure each time you create a new layer version\.
For more examples, see [Granting layer access to other accounts](access-control-resource-based.md#permissions-resource-xaccountlayer)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
1fff2df6b5af-0
|
Use the AWS Serverless Application Model \(AWS SAM\) in your AWS CloudFormation templates to automate the creation and mapping of layers in your application\. The `AWS::Serverless::LayerVersion` resource type creates a layer version that you can reference from your function configuration\.
**Example [blank\-nodejs/template\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/template.yml) – Serverless resources**
```
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Lambda application that calls the Lambda API.
Resources:
function:
Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html)
Properties:
Handler: index.handler
Runtime: nodejs12.x
CodeUri: function/.
Description: Call the AWS Lambda API
Timeout: 10
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
cf7d978a4272-0
|
Policies:
- AWSLambdaBasicExecutionRole
- AWSLambdaReadOnlyAccess
- AWSXrayWriteOnlyAccess
Tracing: Active
Layers:
- !Ref libs
libs:
Type: [AWS::Serverless::LayerVersion](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html)
Properties:
LayerName: blank-nodejs-lib
Description: Dependencies for the blank sample app.
ContentUri: lib/.
CompatibleRuntimes:
- nodejs12.x
```
When you update your dependencies and deploy, AWS SAM creates a new version of the layer and updates the mapping\. If you deploy changes to your code without modifying your dependencies, AWS SAM skips the layer update, saving upload time\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
3bd4524835fb-0
|
The GitHub repository for this guide provides [sample applications](lambda-samples.md) that demonstrate the use of layers for dependency management\.
+ **Node\.js** – [blank\-nodejs](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-nodejs)
+ **Python** – [blank\-python](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-python)
+ **Ruby** – [blank\-ruby](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-ruby)
+ **Java** – [blank\-java](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-java)
For more information about the blank sample app, see [Blank function sample application for AWS Lambda](samples-blank.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-layers.md
|
3d6370107333-0
|
To get started with AWS Lambda, use the Lambda console to create a function\. In a few minutes, you can create a function, invoke it, and view logs, metrics, and trace data\.
**Note**
To use Lambda and other AWS services, you need an AWS account\. If you don't have an account, visit [aws\.amazon\.com](https://aws.amazon.com/) and choose **Create an AWS Account**\. For detailed instructions, see [Create and activate an AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/)\.
As a best practice, you should also create an AWS Identity and Access Management \(IAM\) user with administrator permissions and use that for all work that does not require root credentials\. Create a password for console access, and access keys to use command line tools\. See [Creating your first IAM admin user and group](https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html) in the *IAM User Guide* for instructions\.
You can author functions in the Lambda console—or with an IDE toolkit, command line tools, or SDKs\. The Lambda console provides a [code editor](code-editor.md) for noncompiled languages that lets you modify and test code quickly\. The [AWS CLI](gettingstarted-awscli.md) gives you direct access to the Lambda API for advanced configuration and automation use cases\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started.md
|
3d6370107333-1
|
**Topics**
+ [Create a Lambda function with the console](getting-started-create-function.md)
+ [Creating functions using the AWS Lambda console editor](code-editor.md)
+ [Using AWS Lambda with the AWS Command Line Interface](gettingstarted-awscli.md)
+ [AWS Lambda concepts](gettingstarted-concepts.md)
+ [AWS Lambda features](gettingstarted-features.md)
+ [Tools for working with AWS Lambda](gettingstarted-tools.md)
+ [AWS Lambda quotas](gettingstarted-limits.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started.md
|
869836519e1c-0
|
You can use AWS Lambda to process lifecycle events from Amazon Elastic Compute Cloud and manage Amazon EC2 resources\. Amazon EC2 sends events to Amazon CloudWatch Events for lifecycle events such as when an instance changes state, when an Amazon Elastic Block Store volume snapshot completes, or when a spot instance is scheduled to be terminated\. You configure CloudWatch Events to forward those events to a Lambda function for processing\.
CloudWatch Events invokes your Lambda function asynchronously with the event document from Amazon EC2\.
**Example instance lifecycle event**
```
{
"version": "0",
"id": "b6ba298a-7732-2226-xmpl-976312c1a050",
"detail-type": "EC2 Instance State-change Notification",
"source": "aws.ec2",
"account": "123456798012",
"time": "2019-10-02T17:59:30Z",
"region": "us-east-2",
"resources": [
"arn:aws:ec2:us-east-2:123456798012:instance/i-0c314xmplcd5b8173"
],
"detail": {
"instance-id": "i-0c314xmplcd5b8173",
"state": "running"
}
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-ec2.md
|
869836519e1c-1
|
"state": "running"
}
}
```
For details on configuring events in CloudWatch Events, see [Using AWS Lambda with Amazon CloudWatch Events](services-cloudwatchevents.md)\. For an example function that processes Amazon EBS snapshot notifications, see [Amazon CloudWatch Events for Amazon EBS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-cloud-watch-events.html) in the Amazon EC2 User Guide for Linux Instances\.
You can also use the AWS SDK to manage instances and other resources with the Amazon EC2 API\. For a tutorial with a sample application in C\#, see [Tutorial: Using AWS SDK for \.NET to manage Amazon EC2 Spot Instances](services-ec2-tutorial.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-ec2.md
|
a441bdde8fe4-0
|
To process lifecycle events from Amazon EC2, CloudWatch Events needs permission to invoke your function\. This permission comes from the function's [resource\-based policy](access-control-resource-based.md)\. If you use the CloudWatch Events console to configure an event trigger, the console updates the resource\-based policy on your behalf\. Otherwise, add a statement like the following:
**Example resource\-based policy statement for Amazon EC2 lifecycle notifications**
```
{
"Sid": "ec2-events",
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:us-east-2:12456789012:function:my-function",
"Condition": {
"ArnLike": {
"AWS:SourceArn": "arn:aws:events:us-east-2:12456789012:rule/*"
}
}
}
```
To add a statement, use the `add-permission` AWS CLI command\.
```
aws lambda add-permission --action lambda:InvokeFunction --statement-id ec2-events \
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-ec2.md
|
a441bdde8fe4-1
|
```
aws lambda add-permission --action lambda:InvokeFunction --statement-id ec2-events \
--principal events.amazonaws.com --function-name my-function --source-arn 'arn:aws:events:us-east-2:12456789012:rule/*'
```
If your function uses the AWS SDK to manage Amazon EC2 resources, add Amazon EC2 permissions to the function's [execution role](lambda-intro-execution-role.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-ec2.md
|
2214fba8e205-0
|
Details about a function's configuration\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-0
|
**CodeSha256** <a name="SSS-Type-FunctionConfiguration-CodeSha256"></a>
The SHA256 hash of the function's deployment package\.
Type: String
Required: No
**CodeSize** <a name="SSS-Type-FunctionConfiguration-CodeSize"></a>
The size of the function's deployment package, in bytes\.
Type: Long
Required: No
**DeadLetterConfig** <a name="SSS-Type-FunctionConfiguration-DeadLetterConfig"></a>
The function's dead letter queue\.
Type: [DeadLetterConfig](API_DeadLetterConfig.md) object
Required: No
**Description** <a name="SSS-Type-FunctionConfiguration-Description"></a>
The function's description\.
Type: String
Length Constraints: Minimum length of 0\. Maximum length of 256\.
Required: No
**Environment** <a name="SSS-Type-FunctionConfiguration-Environment"></a>
The function's environment variables\.
Type: [EnvironmentResponse](API_EnvironmentResponse.md) object
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-1
|
The function's environment variables\.
Type: [EnvironmentResponse](API_EnvironmentResponse.md) object
Required: No
**FileSystemConfigs** <a name="SSS-Type-FunctionConfiguration-FileSystemConfigs"></a>
Connection settings for an Amazon EFS file system\.
Type: Array of [FileSystemConfig](API_FileSystemConfig.md) objects
Array Members: Maximum number of 1 item\.
Required: No
**FunctionArn** <a name="SSS-Type-FunctionConfiguration-FunctionArn"></a>
The function's Amazon Resource Name \(ARN\)\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_\.]+(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: No
**FunctionName** <a name="SSS-Type-FunctionConfiguration-FunctionName"></a>
The name of the function\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 170\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-2
|
The name of the function\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 170\.
Pattern: `(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_\.]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: No
**Handler** <a name="SSS-Type-FunctionConfiguration-Handler"></a>
The function that Lambda calls to begin executing your function\.
Type: String
Length Constraints: Maximum length of 128\.
Pattern: `[^\s]+`
Required: No
**KMSKeyArn** <a name="SSS-Type-FunctionConfiguration-KMSKeyArn"></a>
The KMS key that's used to encrypt the function's environment variables\. This key is only returned if you've configured a customer managed CMK\.
Type: String
Pattern: `(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()`
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-3
|
Required: No
**LastModified** <a name="SSS-Type-FunctionConfiguration-LastModified"></a>
The date and time that the function was last updated, in [ISO\-8601 format](https://www.w3.org/TR/NOTE-datetime) \(YYYY\-MM\-DDThh:mm:ss\.sTZD\)\.
Type: String
Required: No
**LastUpdateStatus** <a name="SSS-Type-FunctionConfiguration-LastUpdateStatus"></a>
The status of the last update that was performed on the function\. This is first set to `Successful` after function creation completes\.
Type: String
Valid Values:` Successful | Failed | InProgress`
Required: No
**LastUpdateStatusReason** <a name="SSS-Type-FunctionConfiguration-LastUpdateStatusReason"></a>
The reason for the last update that was performed on the function\.
Type: String
Required: No
**LastUpdateStatusReasonCode** <a name="SSS-Type-FunctionConfiguration-LastUpdateStatusReasonCode"></a>
The reason code for the last update that was performed on the function\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-4
|
The reason code for the last update that was performed on the function\.
Type: String
Valid Values:` EniLimitExceeded | InsufficientRolePermissions | InvalidConfiguration | InternalError | SubnetOutOfIPAddresses | InvalidSubnet | InvalidSecurityGroup`
Required: No
**Layers** <a name="SSS-Type-FunctionConfiguration-Layers"></a>
The function's [ layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)\.
Type: Array of [Layer](API_Layer.md) objects
Required: No
**MasterArn** <a name="SSS-Type-FunctionConfiguration-MasterArn"></a>
For Lambda@Edge functions, the ARN of the master function\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_]+(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: No
**MemorySize** <a name="SSS-Type-FunctionConfiguration-MemorySize"></a>
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-5
|
**MemorySize** <a name="SSS-Type-FunctionConfiguration-MemorySize"></a>
The memory that's allocated to the function\.
Type: Integer
Valid Range: Minimum value of 128\. Maximum value of 3008\.
Required: No
**RevisionId** <a name="SSS-Type-FunctionConfiguration-RevisionId"></a>
The latest updated revision of the function or alias\.
Type: String
Required: No
**Role** <a name="SSS-Type-FunctionConfiguration-Role"></a>
The function's execution role\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+`
Required: No
**Runtime** <a name="SSS-Type-FunctionConfiguration-Runtime"></a>
The runtime environment for the Lambda function\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-6
|
The runtime environment for the Lambda function\.
Type: String
Valid Values:` nodejs10.x | nodejs12.x | java8 | java8.al2 | java11 | python2.7 | python3.6 | python3.7 | python3.8 | dotnetcore2.1 | dotnetcore3.1 | go1.x | ruby2.5 | ruby2.7 | provided | provided.al2`
Required: No
**State** <a name="SSS-Type-FunctionConfiguration-State"></a>
The current state of the function\. When the state is `Inactive`, you can reactivate the function by invoking it\.
Type: String
Valid Values:` Pending | Active | Inactive | Failed`
Required: No
**StateReason** <a name="SSS-Type-FunctionConfiguration-StateReason"></a>
The reason for the function's current state\.
Type: String
Required: No
**StateReasonCode** <a name="SSS-Type-FunctionConfiguration-StateReasonCode"></a>
The reason code for the function's current state\. When the code is `Creating`, you can't invoke or modify the function\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-7
|
Type: String
Valid Values:` Idle | Creating | Restoring | EniLimitExceeded | InsufficientRolePermissions | InvalidConfiguration | InternalError | SubnetOutOfIPAddresses | InvalidSubnet | InvalidSecurityGroup`
Required: No
**Timeout** <a name="SSS-Type-FunctionConfiguration-Timeout"></a>
The amount of time in seconds that Lambda allows a function to run before stopping it\.
Type: Integer
Valid Range: Minimum value of 1\.
Required: No
**TracingConfig** <a name="SSS-Type-FunctionConfiguration-TracingConfig"></a>
The function's AWS X\-Ray tracing configuration\.
Type: [TracingConfigResponse](API_TracingConfigResponse.md) object
Required: No
**Version** <a name="SSS-Type-FunctionConfiguration-Version"></a>
The version of the Lambda function\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 1024\.
Pattern: `(\$LATEST|[0-9]+)`
Required: No
**VpcConfig** <a name="SSS-Type-FunctionConfiguration-VpcConfig"></a>
The function's networking configuration\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
dd77ab458bed-8
|
The function's networking configuration\.
Type: [VpcConfigResponse](API_VpcConfigResponse.md) object
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
93ec5cae3358-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/FunctionConfiguration)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/FunctionConfiguration)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/FunctionConfiguration)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/FunctionConfiguration)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionConfiguration.md
|
7286f53febfe-0
|
A destination for events that failed processing\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_OnFailure.md
|
b68c85231d14-0
|
**Destination** <a name="SSS-Type-OnFailure-Destination"></a>
The Amazon Resource Name \(ARN\) of the destination resource\.
Type: String
Length Constraints: Minimum length of 0\. Maximum length of 350\.
Pattern: `^$|arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-])+:([a-z]{2}(-gov)?-[a-z]+-\d{1})?:(\d{12})?:(.*)`
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_OnFailure.md
|
ea40a3446c4c-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/OnFailure)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/OnFailure)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/OnFailure)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/OnFailure)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_OnFailure.md
|
58a712db8190-0
|
A configuration object that specifies the destination of an event after Lambda processes it\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DestinationConfig.md
|
61700ed8b5b6-0
|
**OnFailure** <a name="SSS-Type-DestinationConfig-OnFailure"></a>
The destination configuration for failed invocations\.
Type: [OnFailure](API_OnFailure.md) object
Required: No
**OnSuccess** <a name="SSS-Type-DestinationConfig-OnSuccess"></a>
The destination configuration for successful invocations\.
Type: [OnSuccess](API_OnSuccess.md) object
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DestinationConfig.md
|
80d530993d51-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/DestinationConfig)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/DestinationConfig)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/DestinationConfig)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/DestinationConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DestinationConfig.md
|
bb531935494a-0
|
Configures options for [asynchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html) on a function, version, or alias\. If a configuration already exists for a function, version, or alias, this operation overwrites it\. If you exclude any settings, they are removed\. To set one option without affecting existing settings for other options, use [UpdateFunctionEventInvokeConfig](API_UpdateFunctionEventInvokeConfig.md)\.
By default, Lambda retries an asynchronous invocation twice if the function returns an error\. It retains events in a queue for up to six hours\. When an event fails all processing attempts or stays in the asynchronous invocation queue for too long, Lambda discards it\. To retain discarded events, configure a dead\-letter queue with [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md)\.
To send an invocation record to a queue, topic, function, or event bus, specify a [destination](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations)\. You can configure separate destinations for successful invocations \(on\-success\) and events that fail all processing attempts \(on\-failure\)\. You can configure destinations in addition to or instead of a dead\-letter queue\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
5b4ea68912ce-0
|
```
PUT /2019-09-25/functions/FunctionName/event-invoke-config?Qualifier=Qualifier HTTP/1.1
Content-type: application/json
{
"DestinationConfig": {
"OnFailure": {
"Destination": "string"
},
"OnSuccess": {
"Destination": "string"
}
},
"MaximumEventAgeInSeconds": number,
"MaximumRetryAttempts": number
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
4098cc9b1326-0
|
The request uses the following URI parameters\.
** [FunctionName](#API_PutFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-request-FunctionName"></a>
The name of the Lambda function, version, or alias\.
**Name formats**
+ **Function name** \- `my-function` \(name\-only\), `my-function:v1` \(with alias\)\.
+ **Function ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:my-function`\.
+ **Partial ARN** \- `123456789012:function:my-function`\.
You can append a version number or alias to any of the formats\. The length constraint applies only to the full ARN\. If you specify only the function name, it is limited to 64 characters in length\.
Length Constraints: Minimum length of 1\. Maximum length of 140\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
4098cc9b1326-1
|
Length Constraints: Minimum length of 1\. Maximum length of 140\.
Pattern: `(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: Yes
** [Qualifier](#API_PutFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-request-Qualifier"></a>
A version number or alias name\.
Length Constraints: Minimum length of 1\. Maximum length of 128\.
Pattern: `(|[a-zA-Z0-9$_-]+)`
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
c1d5aae80968-0
|
The request accepts the following data in JSON format\.
** [DestinationConfig](#API_PutFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-request-DestinationConfig"></a>
A destination for events after they have been sent to a function for processing\.
**Destinations**
+ **Function** \- The Amazon Resource Name \(ARN\) of a Lambda function\.
+ **Queue** \- The ARN of an SQS queue\.
+ **Topic** \- The ARN of an SNS topic\.
+ **Event Bus** \- The ARN of an Amazon EventBridge event bus\.
Type: [DestinationConfig](API_DestinationConfig.md) object
Required: No
** [MaximumEventAgeInSeconds](#API_PutFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-request-MaximumEventAgeInSeconds"></a>
The maximum age of a request that Lambda sends to a function for processing\.
Type: Integer
Valid Range: Minimum value of 60\. Maximum value of 21600\.
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
c1d5aae80968-1
|
Type: Integer
Valid Range: Minimum value of 60\. Maximum value of 21600\.
Required: No
** [MaximumRetryAttempts](#API_PutFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-request-MaximumRetryAttempts"></a>
The maximum number of times to retry when the function returns an error\.
Type: Integer
Valid Range: Minimum value of 0\. Maximum value of 2\.
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
ec80d1be65f0-0
|
```
HTTP/1.1 200
Content-type: application/json
{
"DestinationConfig": {
"OnFailure": {
"Destination": "string"
},
"OnSuccess": {
"Destination": "string"
}
},
"FunctionArn": "string",
"LastModified": number,
"MaximumEventAgeInSeconds": number,
"MaximumRetryAttempts": number
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
98a3e3aac4c8-0
|
If the action is successful, the service sends back an HTTP 200 response\.
The following data is returned in JSON format by the service\.
** [DestinationConfig](#API_PutFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-response-DestinationConfig"></a>
A destination for events after they have been sent to a function for processing\.
**Destinations**
+ **Function** \- The Amazon Resource Name \(ARN\) of a Lambda function\.
+ **Queue** \- The ARN of an SQS queue\.
+ **Topic** \- The ARN of an SNS topic\.
+ **Event Bus** \- The ARN of an Amazon EventBridge event bus\.
Type: [DestinationConfig](API_DestinationConfig.md) object
** [FunctionArn](#API_PutFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-response-FunctionArn"></a>
The Amazon Resource Name \(ARN\) of the function\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
98a3e3aac4c8-1
|
The Amazon Resource Name \(ARN\) of the function\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_]+(:(\$LATEST|[a-zA-Z0-9-_]+))?`
** [LastModified](#API_PutFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-response-LastModified"></a>
The date and time that the configuration was last updated, in Unix time seconds\.
Type: Timestamp
** [MaximumEventAgeInSeconds](#API_PutFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-response-MaximumEventAgeInSeconds"></a>
The maximum age of a request that Lambda sends to a function for processing\.
Type: Integer
Valid Range: Minimum value of 60\. Maximum value of 21600\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
98a3e3aac4c8-2
|
Type: Integer
Valid Range: Minimum value of 60\. Maximum value of 21600\.
** [MaximumRetryAttempts](#API_PutFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-PutFunctionEventInvokeConfig-response-MaximumRetryAttempts"></a>
The maximum number of times to retry when the function returns an error\.
Type: Integer
Valid Range: Minimum value of 0\. Maximum value of 2\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
5bc8a0fa122a-0
|
**InvalidParameterValueException**
One of the parameters in the request is invalid\.
HTTP Status Code: 400
**ResourceNotFoundException**
The resource specified in the request does not exist\.
HTTP Status Code: 404
**ServiceException**
The AWS Lambda service encountered an internal error\.
HTTP Status Code: 500
**TooManyRequestsException**
The request throughput limit was exceeded\.
HTTP Status Code: 429
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
6083f5c045c0-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS Command Line Interface](https://docs.aws.amazon.com/goto/aws-cli/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/PutFunctionEventInvokeConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
6083f5c045c0-1
|
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/PutFunctionEventInvokeConfig)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/PutFunctionEventInvokeConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutFunctionEventInvokeConfig.md
|
96ac4f5dc979-0
|
Sample code is available for the following languages\.
**Topics**
+ [Node\.js](#with-ddb-example-deployment-pkg-nodejs)
+ [Java 11](#with-ddb-example-deployment-pkg-java)
+ [C\#](#with-ddb-example-deployment-pkg-dotnet)
+ [Python 3](#with-ddb-example-deployment-pkg-python)
+ [Go](#with-ddb-example-deployment-pkg-go)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
ac06d2ec3bc4-0
|
The following example processes messages from DynamoDB, and logs their contents\.
**Example ProcessDynamoDBStream\.js**
```
console.log('Loading function');
exports.lambda_handler = function(event, context, callback) {
console.log(JSON.stringify(event, null, 2));
event.Records.forEach(function(record) {
console.log(record.eventID);
console.log(record.eventName);
console.log('DynamoDB Record: %j', record.dynamodb);
});
callback(null, "message");
};
```
Zip up the sample code to create a deployment package\. For instructions, see [AWS Lambda deployment package in Node\.js](nodejs-package.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
30099279a4d5-0
|
The following example processes messages from DynamoDB, and logs their contents\. `handleRequest` is the handler that AWS Lambda invokes and provides event data\. The handler uses the predefined `DynamodbEvent` class, which is defined in the `aws-lambda-java-events` library\.
**Example DDBEventProcessor\.java**
```
package example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.DynamodbEvent;
import com.amazonaws.services.lambda.runtime.events.DynamodbEvent.DynamodbStreamRecord;
public class DDBEventProcessor implements
RequestHandler<DynamodbEvent, String> {
public String handleRequest(DynamodbEvent ddbEvent, Context context) {
for (DynamodbStreamRecord record : ddbEvent.getRecords()){
System.out.println(record.getEventID());
System.out.println(record.getEventName());
System.out.println(record.getDynamodb().toString());
}
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
30099279a4d5-1
|
System.out.println(record.getDynamodb().toString());
}
return "Successfully processed " + ddbEvent.getRecords().size() + " records.";
}
}
```
If the handler returns normally without exceptions, Lambda considers the input batch of records as processed successfully and begins reading new records in the stream\. If the handler throws an exception, Lambda considers the input batch of records as not processed and invokes the function with the same batch of records again\.
**Dependencies**
+ `aws-lambda-java-core`
+ `aws-lambda-java-events`
Build the code with the Lambda library dependencies to create a deployment package\. For instructions, see [AWS Lambda deployment package in Java](java-package.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
e09080731d72-0
|
The following example processes messages from DynamoDB, and logs their contents\. `ProcessDynamoEvent` is the handler that AWS Lambda invokes and provides event data\. The handler uses the predefined `DynamoDbEvent` class, which is defined in the `Amazon.Lambda.DynamoDBEvents` library\.
**Example ProcessingDynamoDBStreams\.cs**
```
using System;
using System.IO;
using System.Text;
using Amazon.Lambda.Core;
using Amazon.Lambda.DynamoDBEvents;
using Amazon.Lambda.Serialization.Json;
namespace DynamoDBStreams
{
public class DdbSample
{
private static readonly JsonSerializer _jsonSerializer = new JsonSerializer();
public void ProcessDynamoEvent(DynamoDBEvent dynamoEvent)
{
Console.WriteLine($"Beginning to process {dynamoEvent.Records.Count} records...");
foreach (var record in dynamoEvent.Records)
{
Console.WriteLine($"Event ID: {record.EventID}");
Console.WriteLine($"Event Name: {record.EventName}");
string streamRecordJson = SerializeObject(record.Dynamodb);
Console.WriteLine($"DynamoDB Record:");
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
e09080731d72-1
|
string streamRecordJson = SerializeObject(record.Dynamodb);
Console.WriteLine($"DynamoDB Record:");
Console.WriteLine(streamRecordJson);
}
Console.WriteLine("Stream processing complete.");
}
private string SerializeObject(object streamRecord)
{
using (var ms = new MemoryStream())
{
_jsonSerializer.Serialize(streamRecord, ms);
return Encoding.UTF8.GetString(ms.ToArray());
}
}
}
}
```
Replace the `Program.cs` in a \.NET Core project with the above sample\. For instructions, see [AWS Lambda Deployment Package in C\#](csharp-package.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
6d01ae4db6a4-0
|
The following example processes messages from DynamoDB, and logs their contents\.
**Example ProcessDynamoDBStream\.py**
```
from __future__ import print_function
def lambda_handler(event, context):
for record in event['Records']:
print(record['eventID'])
print(record['eventName'])
print('Successfully processed %s records.' % str(len(event['Records'])))
```
Zip up the sample code to create a deployment package\. For instructions, see [AWS Lambda deployment package in Python](python-package.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
16212083b71d-0
|
The following example processes messages from DynamoDB, and logs their contents\.
**Example**
```
import (
"strings"
"github.com/aws/aws-lambda-go/events"
)
func handleRequest(ctx context.Context, e events.DynamoDBEvent) {
for _, record := range e.Records {
fmt.Printf("Processing request data for event ID %s, type %s.\n", record.EventID, record.EventName)
// Print new values for attributes of type String
for name, value := range record.Change.NewImage {
if value.DataType() == events.DataTypeString {
fmt.Printf("Attribute name: %s, value: %s\n", name, value.String())
}
}
}
}
```
Build the executable with `go build` and create a deployment package\. For instructions, see [AWS Lambda deployment package in Go](golang-package.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-ddb-create-package.md
|
f5bd391191d4-0
|
In this tutorial, you create a Lambda function to consume messages from an [Amazon SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Welcome.html) queue\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
c5978be9be14-0
|
This tutorial assumes that you have some knowledge of basic Lambda operations and the Lambda console\. If you haven't already, follow the instructions in [Getting started with AWS Lambda](getting-started.md) to create your first Lambda function\.
To follow the procedures in this guide, you will need a command line terminal or shell to run commands\. Commands are shown in listings preceded by a prompt symbol \($\) and the name of the current directory, when appropriate:
```
~/lambda-project$ this is a command
this is output
```
For long commands, an escape character \(`\`\) is used to split a command over multiple lines\.
On Linux and macOS, use your preferred shell and package manager\. On Windows 10, you can [install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows\-integrated version of Ubuntu and Bash\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
31095c684ab3-0
|
Create the [execution role](lambda-intro-execution-role.md) that gives your function permission to access AWS resources\.
**To create an execution role**
1. Open the [roles page](https://console.aws.amazon.com/iam/home#/roles) in the IAM console\.
1. Choose **Create role**\.
1. Create a role with the following properties\.
+ **Trusted entity** – **AWS Lambda**\.
+ **Permissions** – **AWSLambdaSQSQueueExecutionRole**\.
+ **Role name** – **lambda\-sqs\-role**\.
The **AWSLambdaSQSQueueExecutionRole** policy has the permissions that the function needs to read items from Amazon SQS and write logs to CloudWatch Logs\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
763f8fe9b700-0
|
The following example shows how to process each Amazon SQS message in the event input\. See [Using AWS Lambda with Amazon SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html) for an example of an event with multiple messages\. In the example, the code writes each message to a log in CloudWatch Logs\.
**Note**
For sample code in other languages, see [Sample Amazon SQS function code](with-sqs-create-package.md)\.
**Example index\.js**
```
exports.handler = async function(event, context) {
event.Records.forEach(record => {
const { body } = record;
console.log(body);
});
return {};
}
```
**To create the function**
1. Copy the sample code into a file named `index.js`\.
1. Create a deployment package\.
```
$ zip function.zip index.js
```
1. Create a Lambda function with the `create-function` command\.
```
$ aws lambda create-function --function-name ProcessSQSRecord \
--zip-file fileb://function.zip --handler index.handler --runtime nodejs12.x \
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
763f8fe9b700-1
|
--zip-file fileb://function.zip --handler index.handler --runtime nodejs12.x \
--role arn:aws:iam::123456789012:role/lambda-sqs-role
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
f5e4e4d7e1b3-0
|
Invoke your Lambda function manually using the `invoke` AWS Lambda CLI command and a sample Amazon Simple Queue Service event\.
If the handler returns normally without exceptions, Lambda considers the message processed successfully and begins reading new messages in the queue\. Once a message is processed successfully, it is automatically deleted from the queue\. If the handler throws an exception, Lambda considers the input of messages as not processed and invokes the function with the same batch of messages\.
1. Copy the following JSON into a file and save it as `input.txt`\.
```
{
"Records": [
{
"messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
"receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
"body": "test",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1545082649183",
"SenderId": "AIDAIENQZJOLO23YVJ4VO",
"ApproximateFirstReceiveTimestamp": "1545082649185"
},
"messageAttributes": {},
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
f5e4e4d7e1b3-1
|
},
"messageAttributes": {},
"md5OfBody": "098f6bcd4621d373cade4e832627b4f6",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:us-east-2:123456789012:my-queue",
"awsRegion": "us-east-2"
}
]
}
```
1. Execute the following `invoke` command\.
```
$ aws lambda invoke --function-name ProcessSQSRecord \
--payload file://input.txt outputfile.txt
```
1. Verify the output in the `outputfile.txt` file\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
2d53eda50614-0
|
Create an Amazon SQS queue that the Lambda function can use as an event source\.
**To create a queue**
1. Sign in to the AWS Management Console and open the Amazon SQS console at [https://console\.aws\.amazon\.com/sqs/](https://console.aws.amazon.com/sqs/)\.
1. In the Amazon SQS console, create a queue\.
1. Write down or otherwise record the identifying queue ARN \(Amazon Resource Name\)\. You need this in the next step when you associate the queue with your Lambda function\.
Create an event source mapping in AWS Lambda\. This event source mapping associates the Amazon SQS queue with your Lambda function\. After you create this event source mapping, AWS Lambda starts polling the queue\.
Test the end\-to\-end experience\. As you perform queue updates, Amazon Simple Queue Service writes messages to the queue\. AWS Lambda polls the queue, detects new records and executes your Lambda function on your behalf by passing events, in this case Amazon SQS messages, to the function\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
a34ae5d72cb1-0
|
To create a mapping between the specified Amazon SQS queue and the Lambda function, run the following AWS CLI `create-event-source-mapping` command\. After the command executes, write down or otherwise record the UUID\. You'll need this UUID to refer to the event source mapping in any other commands, for example, if you choose to delete the event source mapping\.
```
$ aws lambda create-event-source-mapping --function-name ProcessSQSRecord --batch-size 10 \
--event-source-arn arn:aws:sqs:us-east-2:123456789012:my-queue
```
You can get the list of event source mappings by running the following command\.
```
$ aws lambda list-event-source-mappings --function-name ProcessSQSRecord \
--event-source-arn arn:aws:sqs:us-east-2:123456789012:my-queue
```
The list returns all of the event source mappings you created, and for each mapping it shows the `LastProcessingResult`, among other things\. This field is used to provide an informative message if there are any problems\. Values such as `No records processed` \(indicates that AWS Lambda has not started polling or that there are no records in the queue\) and `OK` \(indicates AWS Lambda successfully read records from the queue and invoked your Lambda function\) indicate that there no issues\. If there are issues, you receive an error message\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
34616d7dc5e4-0
|
Now you can test the setup as follows:
1. In the Amazon SQS console, send messages to the queue\. Amazon SQS writes records of these actions to the queue\.
1. AWS Lambda polls the queue and when it detects updates, it invokes your Lambda function by passing in the event data it finds in the queue\.
1. Your function executes and creates logs in Amazon CloudWatch\. You can verify the logs reported in the Amazon CloudWatch console\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-sqs-example.md
|
bef3a65190c7-0
|
To create a Lambda function you first create a Lambda function deployment package, a \.zip file consisting of your code \(a Go executable\) and any dependencies\.
After you create a deployment package, you may either upload it directly or upload the \.zip file first to an Amazon S3 bucket in the same AWS region where you want to create the Lambda function, and then specify the bucket name and object key name when you create the Lambda function using the console or the AWS CLI\.
Download the Lambda library for Go with `go get`, and compile your executable\.
**Note**
Use version 1\.18\.0 or later of aws\-lambda\-go\.
```
~/my-function$ go get github.com/aws/aws-lambda-go/lambda
~/my-function$ GOOS=linux go build main.go
```
Setting `GOOS` to `linux` ensures that the compiled executable is compatible with the [Go runtime](lambda-runtimes.md), even if you compile it in a non\-Linux environment\.
Create a deployment package by packaging the executable in a ZIP file, and use the AWS CLI to create a function\. The handler parameter must match the name of the executable containing your handler\.
```
~/my-function$ zip function.zip main
~/my-function$ aws lambda create-function --function-name my-function --runtime go1.x \
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-package.md
|
bef3a65190c7-1
|
~/my-function$ aws lambda create-function --function-name my-function --runtime go1.x \
--zip-file fileb://function.zip --handler main \
--role arn:aws:iam::123456789012:role/execution_role
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-package.md
|
da4beffc9a88-0
|
To create a \.zip that will work on AWS Lambda using Windows, we recommend installing the **build\-lambda\-zip** tool\.
**Note**
If you have not already done so, you will need to install [git](https://git-scm.com/) and then add the `git` executable to your Windows `%PATH%` environment variable\.
To download the tool, run the following command:
```
go.exe get -u github.com/aws/aws-lambda-go/cmd/build-lambda-zip
```
Use the tool from your `GOPATH`\. If you have a default installation of Go, the tool will typically be in `%USERPROFILE%\Go\bin`\. Otherwise, navigate to where you installed the Go runtime and do the following:
In cmd\.exe, run the following:
```
set GOOS=linux
go build -o main main.go
%USERPROFILE%\Go\bin\build-lambda-zip.exe -output main.zip main
```
In Powershell, run the following:
```
$env:GOOS = "linux"
$env:CGO_ENABLED = "0"
$env:GOARCH = "amd64"
go build -o main main.go
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-package.md
|
da4beffc9a88-1
|
$env:GOARCH = "amd64"
go build -o main main.go
~\Go\Bin\build-lambda-zip.exe -output main.zip main
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-package.md
|
f3bdd0272565-0
|
Your Lambda function's handler is the method in your function code that processes events\. When your function is invoked, Lambda runs the handler method\. When the handler exits or returns a response, it becomes available to handle another event\.
In the following example, a class named `Handler` defines a handler method named `handleRequest`\. The handler method takes an event and context object as input and returns a string\.
**Example [Handler\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/Handler.java)**
```
package example;
import [com\.amazonaws\.services\.lambda\.runtime\.Context](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Context.java)
import [com\.amazonaws\.services\.lambda\.runtime\.RequestHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
f3bdd0272565-1
|
import [com\.amazonaws\.services\.lambda\.runtime\.LambdaLogger](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaLogger.java)
...
// Handler value: example.Handler
public class Handler implements RequestHandler<Map<String,String>, String>{
Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Override
public String handleRequest(Map<String,String> event, Context context)
{
LambdaLogger logger = context.getLogger();
String response = new String("200 OK");
// log execution details
logger.log("ENVIRONMENT VARIABLES: " + gson.toJson(System.getenv()));
logger.log("CONTEXT: " + gson.toJson(context));
// process event
logger.log("EVENT: " + gson.toJson(event));
logger.log("EVENT TYPE: " + event.getClass().toString());
return response;
}
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
f3bdd0272565-2
|
return response;
}
}
```
The [Lambda runtime](lambda-runtimes.md) receives an event as a JSON\-formatted string and converts it into an object\. It passes the event object to your function handler along with a context object that provides details about the invocation and the function\. You tell the runtime which method to invoke by setting the handler parameter on your function's configuration\.
**Handler formats**
+ `package.Class::method` – Full format\. For example: `example.Handler::handleRequest`\.
+ `package.Class` – Abbreviated format for functions that implement a [handler interface](#java-handler-interfaces)\. For example: `example.Handler`\.
You can add [initialization code](gettingstarted-features.md#gettingstarted-features-programmingmodel) outside of your handler method to reuse resources across multiple invocations\. When the runtime loads your handler, it runs static code and the class constructor\. Resources that are created during initialization stay in memory between invocations, and can be reused by the handler thousands of times\.
In the following example, the logger, serializer, and AWS SDK client are created when the function serves its first event\. Subsequent events served by the same function instance are much faster because those resources already exist\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
f3bdd0272565-3
|
**Example [Handler\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-java/src/main/java/example/Handler.java) – Initialization code**
```
// Handler value: example.Handler
public class Handler implements RequestHandler<SQSEvent, String>{
private static final Logger logger = LoggerFactory.getLogger(Handler.class);
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private static final LambdaAsyncClient lambdaClient = LambdaAsyncClient.create();
...
@Override
public String handleRequest(SQSEvent event, Context context)
{
String response = new String();
// call Lambda API
logger.info("Getting account settings");
CompletableFuture<GetAccountSettingsResponse> accountSettings =
lambdaClient.getAccountSettings(GetAccountSettingsRequest.builder().build());
// log execution details
logger.info("ENVIRONMENT VARIABLES: " + gson.toJson(System.getenv()));
...
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
f3bdd0272565-4
|
...
```
The GitHub repo for this guide provides easy\-to\-deploy sample applications that demonstrate a variety of handler types\. For details, see the [end of this topic](#java-handler-samples)\.
**Topics**
+ [Choosing input and output types](#java-handler-types)
+ [Handler interfaces](#java-handler-interfaces)
+ [Sample handler code](#java-handler-samples)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
8398a9e20b0f-0
|
You specify the type of object that the event maps to in the handler method's signature\. In the preceding example, the Java runtime deserializes the event into a type that implements the `Map<String,String>` interface\. String\-to\-string maps work for flat events like the following:
**Example [Event\.json](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/event.json) – Weather data**
```
{
"temperatureK": 281,
"windKmh": -3,
"humidityPct": 0.55,
"pressureHPa": 1020
}
```
However, the value of each field must be a string or number\. If the event includes a field that has an object as a value, the runtime can't deserialize it and returns an error\.
Choose an input type that works with the event data that your function processes\. You can use a basic type, a generic type, or a well\-defined type\.
**Input types**
+ `Integer`, `Long`, `Double`, etc\. – The event is a number with no additional formatting—for example, `3.5`\. The runtime converts the value into an object of the specified type\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
8398a9e20b0f-1
|
+ `String` – The event is a JSON string, including quotes—for example, `"My string."`\. The runtime converts the value \(without quotes\) into a `String` object\.
+ `Type`, `Map<String,Type>` etc\. – The event is a JSON object\. The runtime deserializes it into an object of the specified type or interface\.
+ `List<Integer>`, `List<String>`, `List<Object>`, etc\. – The event is a JSON array\. The runtime deserializes it into an object of the specified type or interface\.
+ `InputStream` – The event is any JSON type\. The runtime passes a byte stream of the document to the handler without modification\. You deserialize the input and write output to an output stream\.
+ Library type – For events sent by AWS services, use the types in the [aws\-lambda\-java\-events](java-package.md) library\.
If you define your own input type, it should be a deserializable, mutable plain old Java object \(POJO\), with a default constructor and properties for each field in the event\. Keys in the event that don't map to a property as well as properties that aren't included in the event are dropped without error\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
8398a9e20b0f-2
|
The output type can be an object or `void`\. The runtime serializes return values into text\. If the output is an object with fields, the runtime serializes it into a JSON document\. If it's a type that wraps a primitive value, the runtime returns a text representation of that value\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
dd2f77e13514-0
|
The [aws\-lambda\-java\-core](https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-core) library defines two interfaces for handler methods\. Use the provided interfaces to simplify handler configuration and validate the handler method signature at compile time\.
****
+ [com\.amazonaws\.services\.lambda\.runtime\.RequestHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java)
+ [com\.amazonaws\.services\.lambda\.runtime\.RequestStreamHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java)
The `RequestHandler` interface is a generic type that takes two parameters: the input type and the output type\. Both types must be objects\. When you use this interface, the Java runtime deserializes the event into an object with the input type, and serializes the output into text\. Use this interface when the built\-in serialization works with your input and output types\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
dd2f77e13514-1
|
**Example [Handler\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/Handler.java) – Handler interface**
```
// Handler value: example.Handler
public class Handler implements RequestHandler<Map<String,String>, String>{
@Override
public String handleRequest(Map<String,String> event, Context context)
```
To use your own serialization, implement the `RequestStreamHandler` interface\. With this interface, Lambda passes your handler an input stream and output stream\. The handler reads bytes from the input stream, writes to the output stream, and returns void\.
The following example uses buffered reader and writer types to work with the input and output streams\. It uses the [Gson](https://github.com/google/gson) library for serialization and deserialization\.
**Example [HandlerStream\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerStream.java)**
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
dd2f77e13514-2
|
```
import [com\.amazonaws\.services\.lambda\.runtime\.Context](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Context.java)
import [com\.amazonaws\.services\.lambda\.runtime\.RequestStreamHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java)
import [com\.amazonaws\.services\.lambda\.runtime\.LambdaLogger](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaLogger.java)
...
// Handler value: example.HandlerStream
public class HandlerStream implements RequestStreamHandler {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
dd2f77e13514-3
|
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException
{
LambdaLogger logger = context.getLogger();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("US-ASCII")));
PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream, Charset.forName("US-ASCII"))));
try
{
HashMap event = gson.fromJson(reader, HashMap.class);
logger.log("STREAM TYPE: " + inputStream.getClass().toString());
logger.log("EVENT TYPE: " + event.getClass().toString());
writer.write(gson.toJson(event));
if (writer.checkError())
{
logger.log("WARNING: Writer encountered an error.");
}
}
catch (IllegalStateException | JsonSyntaxException exception)
{
logger.log(exception.toString());
}
finally
{
reader.close();
writer.close();
}
}
}
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
dd2f77e13514-4
|
{
reader.close();
writer.close();
}
}
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
9752683c3e2a-0
|
The GitHub repository for this guide includes sample applications that demonstrate the use of various handler types and interfaces\. Each sample application includes scripts for easy deployment and cleanup, an AWS SAM template, and supporting resources\.
**Sample Lambda applications in Java**
+ [blank\-java](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-java) – A Java function that shows the use of Lambda's Java libraries, logging, environment variables, layers, AWS X\-Ray tracing, unit tests, and the AWS SDK\.
+ [java\-basic](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/java-basic) – A minimal Java function with unit tests and variable logging configuration\.
+ [java\-events](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/java-events) – A minimal Java function that uses the [aws\-lambda\-java\-events](java-package.md) library with event types that don't require the AWS SDK as a dependency, such as Amazon API Gateway\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
9752683c3e2a-1
|
+ [java\-events\-v1sdk](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/java-events-v1sdk) – A Java function that uses the [aws\-lambda\-java\-events](java-package.md) library with event types that require the AWS SDK as a dependency \(Amazon Simple Storage Service, Amazon DynamoDB, and Amazon Kinesis\)\.
+ [s3\-java](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/s3-java) – A Java function that processes notification events from Amazon S3 and uses the Java Class Library \(JCL\) to create thumbnails from uploaded image files\.
The `blank-java` and `s3-java` applications take an AWS service event as input and return a string\. The `java-basic` application includes several types of handlers:
+ [Handler\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/Handler.java) – Takes a `Map<String,String>` as input\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
9752683c3e2a-2
|
+ [HandlerInteger\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerInteger.java) – Takes an `Integer` as input\.
+ [HandlerList\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerList.java) – Takes a `List<Integer>` as input\.
+ [HandlerStream\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerStream.java) – Takes an `InputStream` and `OutputStream` as input\.
+ [HandlerString\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerString.java) – Takes a `String` as input\.
+ [HandlerWeatherData\.java](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/java-basic/src/main/java/example/HandlerWeatherData.java) – Takes a custom type as input\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
9752683c3e2a-3
|
To test different handler types, just change the handler value in the AWS SAM template\. For detailed instructions, see the sample application's readme file\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-handler.md
|
80bc40f21c6d-0
|
Provides configuration information about a Lambda function [alias](https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_AliasConfiguration.md
|
45c04c662b60-0
|
**AliasArn** <a name="SSS-Type-AliasConfiguration-AliasArn"></a>
The Amazon Resource Name \(ARN\) of the alias\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_]+(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: No
**Description** <a name="SSS-Type-AliasConfiguration-Description"></a>
A description of the alias\.
Type: String
Length Constraints: Minimum length of 0\. Maximum length of 256\.
Required: No
**FunctionVersion** <a name="SSS-Type-AliasConfiguration-FunctionVersion"></a>
The function version that the alias invokes\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 1024\.
Pattern: `(\$LATEST|[0-9]+)`
Required: No
**Name** <a name="SSS-Type-AliasConfiguration-Name"></a>
The name of the alias\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_AliasConfiguration.md
|
45c04c662b60-1
|
The name of the alias\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 128\.
Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)`
Required: No
**RevisionId** <a name="SSS-Type-AliasConfiguration-RevisionId"></a>
A unique identifier that changes when you update the alias\.
Type: String
Required: No
**RoutingConfig** <a name="SSS-Type-AliasConfiguration-RoutingConfig"></a>
The [routing configuration](https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html) of the alias\.
Type: [AliasRoutingConfiguration](API_AliasRoutingConfiguration.md) object
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_AliasConfiguration.md
|
703b01b3fd84-0
|
For more information about using this API in one of the language\-specific AWS SDKs, see the following:
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/AliasConfiguration)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/AliasConfiguration)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/AliasConfiguration)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/AliasConfiguration)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_AliasConfiguration.md
|
e14baafc526d-0
|
Returns a list of [aliases](https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html) for a Lambda function\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListAliases.md
|
a2487d65bcbc-0
|
```
GET /2015-03-31/functions/FunctionName/aliases?FunctionVersion=FunctionVersion&Marker=Marker&MaxItems=MaxItems HTTP/1.1
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListAliases.md
|
051a41a00b34-0
|
The request uses the following URI parameters\.
** [FunctionName](#API_ListAliases_RequestSyntax) ** <a name="SSS-ListAliases-request-FunctionName"></a>
The name of the Lambda function\.
**Name formats**
+ **Function name** \- `MyFunction`\.
+ **Function ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:MyFunction`\.
+ **Partial ARN** \- `123456789012:function:MyFunction`\.
The length constraint applies only to the full ARN\. If you specify only the function name, it is limited to 64 characters in length\.
Length Constraints: Minimum length of 1\. Maximum length of 140\.
Pattern: `(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: Yes
** [FunctionVersion](#API_ListAliases_RequestSyntax) ** <a name="SSS-ListAliases-request-FunctionVersion"></a>
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListAliases.md
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.