id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
0decf549b55f-1
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/DeleteEventSourceMapping) + [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/DeleteEventSourceMapping) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/DeleteEventSourceMapping)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DeleteEventSourceMapping.md
bc8dcf752181-0
You can configure a function to mount an Amazon Elastic File System \(Amazon EFS\) file system to a local directory\. With Amazon EFS, your function code can access and modify shared resources safely and at high concurrency\. A function connects to a file system over the local network in a VPC\. The subnets that your function connects to can be the same subnets that contain mount points for your file system, or subnets in the same Availability Zone that can route NFS traffic \(port 2049\) to the file system\. **Note** If your function is not already connected to a VPC, see [Configuring a Lambda function to access resources in a VPC](configuration-vpc.md)\. **To configure file system access** 1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\. 1. Choose a function\. 1. Under **File system**, choose **Add file system**\. 1. Configure the following properties: + **EFS file system** – The access point for a file system in the same VPC\. + **Local mount path** – The location where the file system is mounted on the Lambda function, starting with `/mnt/`\. **Pricing**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
bc8dcf752181-1
**Pricing** Amazon EFS charges for storage and throughput, with rates that vary by storage class\. For details, see [Amazon EFS pricing](https://aws.amazon.com/efs/pricing)\. Lambda charges for data transfer between VPCs\. This only applies if your function's VPC is peered to another VPC with a file system\. The rates are the same as for Amazon EC2 data transfer between VPCs in the same Region\. For details, see [Lambda pricing](https://aws.amazon.com/lambda/pricing)\. For more information about Lambda's integration with Amazon EFS, see [Using Amazon EFS with Lambda](services-efs.md)\. **Topics** + [Configuring a file system and access point](#configuration-filesystem-setup) + [Execution role and user permissions](#configuration-filesystem-permissions) + [Configuring file system access with the Lambda API](#configuration-filesystem-api) + [AWS CloudFormation and AWS SAM](#configuration-filesystem-cloudformation) + [Sample applications](#configuration-filesystem-samples)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
6e5bda294ea4-0
Create a file system in Amazon EFS with a mount target in every Availability Zone that your function connects to\. For performance and resilience, use at least two Availability Zones\. For example, in a simple configuration you could have a VPC with two private subnets in separate Availability Zones\. The function connects to both subnets and a mount target is available in each\. Ensure that NFS traffic \(port 2049\) is allowed by the security groups used by the function and mount targets\. **Note** When you create a file system, you choose a performance mode that can't be changed later\. **General purpose** mode has lower latency, and **Max I/O** mode supports a higher maximum throughput and IOPS\. For help choosing, see [Amazon EFS performance](https://docs.aws.amazon.com/efs/latest/ug/performance.html) in the *Amazon Elastic File System User Guide*\. An access point connects each instance of the function to the right mount target for the Availability Zone it connects to\. For best performance, create an access point with a non\-root path, and limit the number of files that you create in each directory\. User and owner IDs are required, but they don't need to have a specific value\. The following example creates a directory named `my-function` on the file system and sets the owner ID to 1001 with standard directory permissions \(755\)\. **Example access point configuration** + **Name** – `files` + **User ID** – `1001` + **Group ID** – `1001`
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
6e5bda294ea4-1
+ **User ID** – `1001` + **Group ID** – `1001` + **Path** – `/my-function` + **Permissions** – `755` + **Owner user ID** – `1001` + **Group user ID** – `1001` When a function uses the access point, it is given user ID 1001 and has full access to the directory\. For more information, see the following topics in the *Amazon Elastic File System User Guide*: + [Creating resources for Amazon EFS](https://docs.aws.amazon.com/efs/latest/ug/creating-using.html) + [Working with users, groups, and permissions](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs-nfs-permissions.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
0d0fea973c4b-0
Lambda uses your function's permissions to mount file systems\. To connect to a file system, your function's execution role must have the following permissions in addition to the [permissions required to connect to the file system's VPC](configuration-vpc.md#vpc-permissions): **Execution role permissions** + **elasticfilesystem:ClientMount** + **elasticfilesystem:ClientWrite \(not required for read\-only connections\)** These permissions are included in the **AmazonElasticFileSystemClientReadWriteAccess** managed policy\. When you configure a file system, Lambda uses your permissions to verify mount targets\. To configure a function to connect to a file system, your IAM user needs the following permissions: **User permissions** + **elasticfilesystem:DescribeMountTargets**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
00d94457c203-0
Use the following API operations to connect your Lambda function to a file system: + [CreateFunction](API_CreateFunction.md) + [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md) To connect a function a file system, use the `update-function-configuration` command\. The following example connects a function named `my-function` to a file system with ARN of an access point\. ``` $ ARN=arn:aws:elasticfilesystem:us-east-2:123456789012:access-point/fsap-015cxmplb72b405fd $ aws lambda update-function-configuration --function-name my-function \ --fs-config FileSystemArn=$ARN,LocalMountPath=/mnt/efs0 ``` You can get the ARN of a file system's access point with the `describe-access-points` command\. ``` $ aws efs describe-access-points { "AccessPoints": [ { "ClientToken": "console-aa50c1fd-xmpl-48b5-91ce-57b27a3b1017", "Name": "lambda-ap", "Tags": [ { "Key": "Name", "Value": "lambda-ap"
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
00d94457c203-1
"Tags": [ { "Key": "Name", "Value": "lambda-ap" } ], "AccessPointId": "fsap-015cxmplb72b405fd", "AccessPointArn": "arn:aws:elasticfilesystem:us-east-2:123456789012:access-point/fsap-015cxmplb72b405fd", "FileSystemId": "fs-aea3xmpl", "RootDirectory": { "Path": "/" }, "OwnerId": "123456789012", "LifeCycleState": "available" } ] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
f6c6b3d865c5-0
You can use AWS CloudFormation and the AWS Serverless Application Model \(AWS SAM\) to automate the creation of Lambda applications\. To enable a file system connection on an AWS SAM `AWS::Serverless::Function` resource, use the `FileSystemConfigs` property\. **Example template\.yml – File system configuration** ``` Resources: VPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 Subnet1: Type: AWS::EC2::Subnet Properties: VpcId: Ref: VPC CidrBlock: 10.0.1.0/24 AvailabilityZone: "eu-central-1a" EfsSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: VpcId: Ref: VPC GroupDescription: "mnt target sg" SecurityGroupEgress: - IpProtocol: -1 CidrIp: "0.0.0.0/0" FileSystem: Type: AWS::EFS::FileSystem Properties: PerformanceMode: generalPurpose MountTarget1: Type: AWS::EFS::MountTarget
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
f6c6b3d865c5-1
PerformanceMode: generalPurpose MountTarget1: Type: AWS::EFS::MountTarget Properties: FileSystemId: Ref: FileSystem SubnetId: Ref: Subnet1 SecurityGroups: - Ref: EfsSecurityGroup MyFunctionWithEfs: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: CodeUri: function/. Description: Use a file system. FileSystemConfigs: - Arn: !Sub - "arn:aws:elasticfilesystem:eu-central-1:123456789101:access-point/${ap}" - {ap: !Ref AccessPoint} LocalMountPath: "/mnt/efs0" DependsOn: "MountTarget1" ``` You must add the `DependsOn` to ensure that the mount targets are fully created before the Lambda runs for the first time\. For the AWS CloudFormation `AWS::Lambda::Function` type, the property name and fields are the same\. For more information, see [Using AWS Lambda with AWS CloudFormation](services-cloudformation.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
ad9a88e958a7-0
The GitHub repository for this guide includes a sample application that demonstrates the use of Amazon EFS with a Lambda function\. + [efs\-nodejs](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/efs-nodejs) – A function that uses an Amazon EFS file system in a Amazon VPC\. This sample includes a VPC, file system, mount targets, and access point configured for use with Lambda\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-filesystem.md
99595b9b1ea4-0
You can use Lambda to process [event notifications](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) from Amazon Simple Storage Service\. Amazon S3 can send an event to a Lambda function when an object is created or deleted\. You configure notification settings on a bucket, and grant Amazon S3 permission to invoke a function on the function's resource\-based permissions policy\. **Warning** If your Lambda function uses the same bucket that triggers it, it could cause the function to execute in a loop\. For example, if the bucket triggers a function each time an object is uploaded, and the function uploads an object to the bucket, then the function indirectly triggers itself\. To avoid this, use two buckets, or configure the trigger to only apply to a prefix used for incoming objects\. Amazon S3 invokes your function [asynchronously](invocation-async.md) with an event that contains details about the object\. The following example shows an event that Amazon S3 sent when a deployment package was uploaded to Amazon S3\. **Example Amazon S3 notification event** ``` { "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "us-east-2", "eventTime": "2019-09-03T19:37:27.192Z",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-s3.md
99595b9b1ea4-1
"eventTime": "2019-09-03T19:37:27.192Z", "eventName": "ObjectCreated:Put", "userIdentity": { "principalId": "AWS:AIDAINPONIXQXHT3IKHL2" }, "requestParameters": { "sourceIPAddress": "205.255.255.255" }, "responseElements": { "x-amz-request-id": "D82B88E5F771F645", "x-amz-id-2": "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=" }, "s3": { "s3SchemaVersion": "1.0", "configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1", "bucket": { "name": "lambda-artifacts-deafc19498e3f2df", "ownerIdentity": { "principalId": "A3I5XTEXAMAI3E" },
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-s3.md
99595b9b1ea4-2
"ownerIdentity": { "principalId": "A3I5XTEXAMAI3E" }, "arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" }, "object": { "key": "b21b84d653bb07b05b1e6b33684dc11b", "size": 1305107, "eTag": "b21b84d653bb07b05b1e6b33684dc11b", "sequencer": "0C0F6F405D6ED209E1" } } } ] } ``` To invoke your function, Amazon S3 needs permission from the function's [resource\-based policy](access-control-resource-based.md)\. When you configure an Amazon S3 trigger in the Lambda console, the console modifies the resource\-based policy to allow Amazon S3 to invoke the function if the bucket name and account ID match\. If you configure the notification in Amazon S3, you use the Lambda API to update the policy\. You can also use the Lambda API to grant permission to another account, or restrict permission to a designated alias\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-s3.md
99595b9b1ea4-3
If your function uses the AWS SDK to manage Amazon S3 resources, it also needs Amazon S3 permissions in its [execution role](lambda-intro-execution-role.md)\. **Topics** + [Tutorial: Using AWS Lambda with Amazon S3](with-s3-example.md) + [Sample Amazon S3 function code](with-s3-example-deployment-pkg.md) + [AWS SAM template for an Amazon S3 application](with-s3-example-use-app-spec.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-s3.md
958d1d8530ad-0
Retrieves the configuration for asynchronous invocation for a function, version, or alias\. To configure options for asynchronous invocation, use [PutFunctionEventInvokeConfig](API_PutFunctionEventInvokeConfig.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunctionEventInvokeConfig.md
dda308b18d66-0
``` GET /2019-09-25/functions/FunctionName/event-invoke-config?Qualifier=Qualifier HTTP/1.1 ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunctionEventInvokeConfig.md
b4e9e2fa56d4-0
The request uses the following URI parameters\. ** [FunctionName](#API_GetFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig.md
b4e9e2fa56d4-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_GetFunctionEventInvokeConfig_RequestSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig.md
51d9a21e6f82-0
The request does not have a request body\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunctionEventInvokeConfig.md
68e52905bb90-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_GetFunctionEventInvokeConfig.md
f1229e7f43bd-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_GetFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig.md
f1229e7f43bd-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_GetFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-response-LastModified"></a> The date and time that the configuration was last updated, in Unix time seconds\. Type: Timestamp ** [MaximumEventAgeInSeconds](#API_GetFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig.md
f1229e7f43bd-2
Type: Integer Valid Range: Minimum value of 60\. Maximum value of 21600\. ** [MaximumRetryAttempts](#API_GetFunctionEventInvokeConfig_ResponseSyntax) ** <a name="SSS-GetFunctionEventInvokeConfig-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_GetFunctionEventInvokeConfig.md
a8704cf1bb57-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_GetFunctionEventInvokeConfig.md
1cb8e62d679c-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/GetFunctionEventInvokeConfig) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/GetFunctionEventInvokeConfig)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunctionEventInvokeConfig.md
1cb8e62d679c-1
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/GetFunctionEventInvokeConfig) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/GetFunctionEventInvokeConfig)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunctionEventInvokeConfig.md
1269d5aacc9b-0
At the time you create a Lambda function, you specify a *handler*, which is a function in your code, that AWS Lambda can invoke when the service executes your code\. Use the following general syntax structure when creating a handler function in Python\. ``` def handler_name(event, context): ... return some_value ``` In the syntax, note the following: + `event` – AWS Lambda uses this parameter to pass in event data to the handler\. This parameter is usually of the Python `dict` type\. It can also be `list`, `str`, `int`, `float`, or `NoneType` type\. When you invoke your function, you determine the content and structure of the event\. When an AWS service invokes your function, the event structure varies by service\. For details, see [Using AWS Lambda with other services](lambda-services.md)\. + `context` – AWS Lambda uses this parameter to provide runtime information to your handler\. For details, see [AWS Lambda context object in Python](python-context.md)\. + Optionally, the handler can return a value\. What happens to the returned value depends on the invocation type you use when invoking the Lambda function:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-handler.md
1269d5aacc9b-1
+ Optionally, the handler can return a value\. What happens to the returned value depends on the invocation type you use when invoking the Lambda function: + If you use the `RequestResponse` invocation type \(synchronous execution\), AWS Lambda returns the result of the Python function call to the client invoking the Lambda function \(in the HTTP response to the invocation request, serialized into JSON\)\. For example, AWS Lambda console uses the `RequestResponse` invocation type, so when you invoke the function using the console, the console will display the returned value\. + If the handler returns objects that can't be serialized by `json.dumps`, the runtime returns an error\. + If the handler returns `None`, as Python functions without a `return` statement implicitly do, the runtime returns `null`\. + If you use the `Event` invocation type \(asynchronous execution\), the value is discarded\. For example, consider the following Python example code\. ``` def my_handler(event, context): message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) return { 'message' : message } ``` This example has one function called `my_handler`\. The function returns a message containing data from the event it received as input\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-handler.md
f387a2ee7783-0
Lambda integrates with AWS X\-Ray to enable you to trace, debug, and optimize Lambda applications\. You can use X\-Ray to trace a request as it traverses resources in your application, from the frontend API to storage and database on the backend\. By simply adding the X\-Ray SDK library to your build configuration, you can record errors and latency for any call that your function makes to an AWS service\. The X\-Ray *service map* shows the flow of requests through your application\. The following example from the [error processor](samples-errorprocessor.md) sample application shows an application with two functions\. The primary function processes events and sometimes returns errors\. The second function processes errors that appear in the first's log group and uses the AWS SDK to call X\-Ray, Amazon S3 and Amazon CloudWatch Logs\. [images/sample-errorprocessor-servicemap-l.png](images/sample-errorprocessor-servicemap-l.png) To trace requests that don't have a tracing header, enable active tracing in your function's configuration\. **To enable active tracing** 1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\. 1. Choose a function\. 1. Under **AWS X\-Ray**, choose **Active tracing**\. 1. Choose **Save**\. **Pricing**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
f387a2ee7783-1
1. Choose **Save**\. **Pricing** X\-Ray has a perpetual free tier\. Beyond the free tier threshold, X\-Ray charges for trace storage and retrieval\. For details, see [AWS X\-Ray pricing](https://aws.amazon.com/xray/pricing/)\. Your function needs permission to upload trace data to X\-Ray\. When you enable active tracing in the Lambda console, Lambda adds the required permissions to your function's [execution role](lambda-intro-execution-role.md)\. Otherwise, add the [AWSXRayDaemonWriteAccess](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess) policy to the execution role\. X\-Ray applies a sampling algorithm to ensure that tracing is efficient, while still providing a representative sample of the requests that your application serves\. The default sampling rule is 1 request per second and 5 percent of additional requests\. This sampling rate cannot be configured for Lambda functions\. When active tracing is enabled, Lambda records a trace for a subset of invocations\. Lambda records two *segments*, which creates two nodes on the service map\. The first node represents the Lambda service that receives the invocation request\. The second node is recorded by the function's [runtime](gettingstarted-concepts.md#gettingstarted-concepts-runtimes)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
f387a2ee7783-2
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/xray-servicemap-function.png) To record detail about calls that your function makes to other resources and services, add the X\-Ray SDK for Java to your build configuration\. The following example shows a Gradle build configuration that includes the libraries that enable automatic instrumentation of AWS SDK for Java 2\.x clients\. **Example [build\.gradle](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-java/build.gradle) – Tracing dependencies** ``` dependencies { implementation platform('software.amazon.awssdk:bom:2.10.73') implementation platform('com.amazonaws:aws-xray-recorder-sdk-bom:2.4.0') implementation 'software.amazon.awssdk:lambda' implementation 'com.amazonaws:aws-xray-recorder-sdk-core' implementation 'com.amazonaws:aws-xray-recorder-sdk-aws-sdk-core' implementation 'com.amazonaws:aws-xray-recorder-sdk-aws-sdk-v2' implementation 'com.amazonaws:aws-xray-recorder-sdk-aws-sdk-v2-instrumentor'
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
f387a2ee7783-3
implementation 'com.amazonaws:aws-xray-recorder-sdk-aws-sdk-v2-instrumentor' ... } ``` The following example shows a trace with 2 segments\. Both are named **my\-function**, but one is type `AWS::Lambda` and the other is `AWS::Lambda::Function`\. The function segment is expanded to show its subsegments\. ![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/nodejs-xray-timeline.png) The first segment represents the invocation request processed by the Lambda service\. The second segment records the work done by your function\. The function segment has 3 subsegments\. + **Initialization** – Represents time spent loading your function and running [initialization code](gettingstarted-features.md#gettingstarted-features-programmingmodel)\. This subsegment only appears for the first event processed by each instance of your function\. + **Invocation** – Represents the work done by your handler code\. By instrumenting your code, you can extend this subsegment with additional subsegments\. + **Overhead** – Represents the work done by the Lambda runtime to prepare to handle the next event\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
f387a2ee7783-4
+ **Overhead** – Represents the work done by the Lambda runtime to prepare to handle the next event\. You can also instrument HTTP clients, record SQL queries, and create custom subsegments with annotations and metadata\. For more information, see [AWS X\-Ray SDK for Java ](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java.html) in the AWS X\-Ray Developer Guide\. **Topics** + [Enabling active tracing with the Lambda API](#java-tracing-api) + [Enabling active tracing with AWS CloudFormation](#java-tracing-cloudformation) + [Storing runtime dependencies in a layer](#java-tracing-layers) + [Tracing in sample applications](#java-tracing-samples)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
1df61b0bdc5a-0
To manage tracing configuration with the AWS CLI or AWS SDK, use the following API operations: + [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md) + [GetFunctionConfiguration](API_GetFunctionConfiguration.md) + [CreateFunction](API_CreateFunction.md) The following example AWS CLI command enables active tracing on a function named my\-function\. ``` $ aws lambda update-function-configuration --function-name my-function \ --tracing-config Mode=Active ``` Tracing mode is part of the version\-specific configuration that is locked when you publish a version of your function\. You can't change the tracing mode on a published version\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
e0a3da76751f-0
To enable active tracing on an `AWS::Lambda::Function` resource in an AWS CloudFormation template, use the `TracingConfig` property\. **Example [function\-inline\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/templates/function-inline.yml) – Tracing configuration** ``` Resources: function: Type: [AWS::Lambda::Function](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html) Properties: TracingConfig: Mode: Active ... ``` For an AWS Serverless Application Model \(AWS SAM\) `AWS::Serverless::Function` resource, use the `Tracing` property\. **Example [template\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/template.yml) – Tracing configuration** ``` Resources: function: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: Tracing: Active
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
e0a3da76751f-1
Properties: Tracing: Active ... ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
6f1e3f53ea52-0
If you use the X\-Ray SDK to instrument AWS SDK clients your function code, your deployment package can become quite large\. To avoid uploading runtime dependencies every time you update your functions code, package them in a [Lambda layer](configuration-layers.md)\. The following example shows an `AWS::Serverless::LayerVersion` resource that stores the SDK for Java and X\-Ray SDK for Java\. **Example [template\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-java/template.yml) – Dependencies layer** ``` Resources: function: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: CodeUri: build/distributions/blank-java.zip 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-java-lib Description: Dependencies for the blank-java sample app.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
6f1e3f53ea52-1
Properties: LayerName: blank-java-lib Description: Dependencies for the blank-java sample app. ContentUri: build/blank-java-lib.zip CompatibleRuntimes: - java8 ``` With this configuration, you only update library layer if you change your runtime dependencies\. The function deployment package only contains your code\. When you update your function code, upload time is much faster than if you include dependencies in the deployment package\. Creating a layer for dependencies requires build configuration changes to generate the layer archive prior to deployment\. For a working example, see the [java\-basic](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/java-basic) sample application\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
51f27b6245e2-0
The GitHub repository for this guide includes sample applications that demonstrate the use of tracing\. 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-tracing.md
51f27b6245e2-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\. All of the sample applications have active tracing enabled for Lambda functions\. The `blank-java` application shows automatic instrumentation of AWS SDK for Java 2\.x clients, segment management for tests, custom subsegments, and the use of Lambda layers to store runtime dependencies\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/blank-java-servicemap.png) This example from the `blank-java` sample application shows nodes for the Lambda service, a function, and the Lambda API\. The function calls the Lambda API to monitor storage use in Lambda\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/java-tracing.md
b822217d20b6-0
When you invoke a function, two types of error can occur\. Invocation errors occur when the invocation request is rejected before your function receives it\. Function errors occur when your function's code or [runtime](lambda-runtimes.md) returns an error\. Depending on the type of error, the type of invocation, and the client or service that invokes the function, the retry behavior and the strategy for managing errors varies\. Issues with the request, caller, or account can cause invocation errors\. Invocation errors include an error type and status code in the response that indicate the cause of the error\. **Common invocation errors** + **Request** – The request event is too large or isn't valid JSON, the function doesn't exist, or a parameter value is the wrong type\. + **Caller** – The user or service doesn't have permission to invoke the function\. + **Account** – The maximum number of function instances are already running, or requests are being made too quickly\. Clients such as the AWS CLI and the AWS SDK retry on client timeouts, throttling errors \(429\), and other errors that aren't caused by a bad request \(500 series\)\. For a full list of invocation errors, see [Invoke](API_Invoke.md)\. Function errors occur when your function code or the runtime that it uses return an error\. **Common function errors** + **Function** – Your function's code throws an exception or returns an error object\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-retries.md
b822217d20b6-1
**Common function errors** + **Function** – Your function's code throws an exception or returns an error object\. + **Runtime** – The runtime terminated your function because it ran out of time, detected a syntax error, or failed to marshal the response object into JSON\. The function exited with an error code\. Unlike invocation errors, function errors don't cause Lambda to return a 400\-series or 500\-series status code\. If the function returns an error, Lambda indicates this by including a header named `X-Amz-Function-Error`, and a JSON\-formatted response with the error message and other details\. For examples of function errors in each language, see the following topics\. + [AWS Lambda function errors in Node\.js](nodejs-exceptions.md) + [AWS Lambda function errors in Python](python-exceptions.md) + [AWS Lambda function errors in Ruby](ruby-exceptions.md) + [AWS Lambda function errors in Java](java-exceptions.md) + [AWS Lambda function errors in Go](golang-exceptions.md) + [AWS Lambda function errors in C\#](csharp-exceptions.md) + [AWS Lambda function errors in PowerShell](powershell-exceptions.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-retries.md
b822217d20b6-2
+ [AWS Lambda function errors in PowerShell](powershell-exceptions.md) When you invoke a function directly, you determine the strategy for handling errors\. You can retry, send the event to a queue for debugging, or ignore the error\. Your function's code might have run completely, partially, or not at all\. If you retry, ensure that your function's code can handle the same event multiple times without causing duplicate transactions or other unwanted side effects\. When you invoke a function indirectly, you need to be aware of the retry behavior of the invoker and any service that the request encounters along the way\. This includes the following scenarios\. + **Asynchronous invocation** – Lambda retries function errors twice\. If the function doesn't have enough capacity to handle all incoming requests, events might wait in the queue for hours or days to be sent to the function\. You can configure a dead\-letter queue on the function to capture events that weren't successfully processed\. For more information, see [Asynchronous invocation](invocation-async.md)\. + **Event source mappings** – Event source mappings that read from streams retry the entire batch of items\. Repeated errors block processing of the affected shard until the error is resolved or the items expire\. To detect stalled shards, you can monitor the [Iterator Age](monitoring-metrics.md) metric\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-retries.md
b822217d20b6-3
For event source mappings that read from a queue, you determine the length of time between retries and destination for failed events by configuring the visibility timeout and redrive policy on the source queue\. For more information, see [AWS Lambda event source mappings](invocation-eventsourcemapping.md) and the service\-specific topics under [Using AWS Lambda with other services](lambda-services.md)\. + **AWS services** – AWS services can invoke your function [synchronously](invocation-sync.md) or asynchronously\. For synchronous invocation, the service decides whether to retry\. Services like API Gateway and Elastic Load Balancing, which proxy requests from an upstream user or client, can also choose to relay the error response back to the requestor\. For asynchronous invocation, the behavior is the same as when you invoke the function asynchronously\. For more information, see the service\-specific topics under [Using AWS Lambda with other services](lambda-services.md) and the invoking service's documentation\. + **Other accounts and clients** – When you grant access to other accounts, you can use [resource\-based policies](access-control-resource-based.md) to restrict the services or resources they can configure to invoke your function\. To protect your function from being overloaded, consider putting an API layer in front of your function with [Amazon API Gateway](services-apigateway.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-retries.md
b822217d20b6-4
To help you deal with errors in Lambda applications, Lambda integrates with services like Amazon CloudWatch and AWS X\-Ray\. You can use a combination of logs, metrics, alarms, and tracing to quickly detect and identify issues in your function code, API, or other resources that support your application\. For more information, see [Monitoring and troubleshooting Lambda applications](lambda-monitoring.md)\. For a sample application that uses a CloudWatch Logs subscription, X\-Ray tracing, and a Lambda function to detect and process errors, see [Error processor sample application for AWS Lambda](samples-errorprocessor.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-retries.md
f6a7e0cb69c8-0
AWS Lambda is integrated with AWS CloudTrail, a service that provides a record of actions taken by a user, role, or an AWS service in AWS Lambda\. CloudTrail captures API calls for AWS Lambda as events\. The calls captured include calls from the AWS Lambda console and code calls to the AWS Lambda API operations\. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for AWS Lambda\. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in **Event history**\. Using the information collected by CloudTrail, you can determine the request that was made to AWS Lambda, the IP address from which the request was made, who made the request, when it was made, and additional details\. To learn more about CloudTrail, including how to configure and enable it, see the [AWS CloudTrail User Guide](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
7f81429750b0-0
CloudTrail is enabled on your AWS account when you create the account\. When supported event activity occurs in AWS Lambda, that activity is recorded in a CloudTrail event along with other AWS service events in **Event history**\. You can view, search, and download recent events in your AWS account\. For more information, see [Viewing events with CloudTrail event history](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)\. For an ongoing record of events in your AWS account, including events for AWS Lambda, you create a trail\. A *trail* enables CloudTrail to deliver log files to an Amazon S3 bucket\. By default, when you create a trail in the console, the trail applies to all AWS Regions\. The trail logs events from all Regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify\. Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs\. For more information, see the following: + [Overview for creating a trail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html) + [CloudTrail supported services and integrations](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
7f81429750b0-1
+ [Configuring Amazon SNS notifications for CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html) + [Receiving CloudTrail log files from multiple regions](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html) and [Receiving CloudTrail log files from multiple accounts](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html) AWS Lambda supports logging the following actions as events in CloudTrail log files: + [AddPermission](API_AddPermission.md) + [CreateEventSourceMapping](API_CreateEventSourceMapping.md) + [CreateFunction](API_CreateFunction.md) \(The `ZipFile` parameter is omitted from the CloudTrail logs for `CreateFunction`\.\) + [DeleteEventSourceMapping](API_DeleteEventSourceMapping.md) + [DeleteFunction](API_DeleteFunction.md) + [GetEventSourceMapping](API_GetEventSourceMapping.md) + [GetFunction](API_GetFunction.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
7f81429750b0-2
+ [GetFunction](API_GetFunction.md) + [GetFunctionConfiguration](API_GetFunctionConfiguration.md) + [GetPolicy](API_GetPolicy.md) + [ListEventSourceMappings](API_ListEventSourceMappings.md) + [ListFunctions](API_ListFunctions.md) + [RemovePermission](API_RemovePermission.md) + [UpdateEventSourceMapping](API_UpdateEventSourceMapping.md) + [UpdateFunctionCode](API_UpdateFunctionCode.md) \(The `ZipFile` parameter is omitted from the CloudTrail logs for `UpdateFunctionCode`\.\) + [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md) Every log entry contains information about who generated the request\. The user identity information in the log helps you determine whether the request was made with root or IAM user credentials, with temporary security credentials for a role or federated user, or by another AWS service\. For more information, see the **userIdentity** field in the [CloudTrail event reference](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
7f81429750b0-3
You can store your log files in your bucket for as long as you want, but you can also define Amazon S3 lifecycle rules to archive or delete log files automatically\. By default, your log files are encrypted by using Amazon S3 server\-side encryption \(SSE\)\. You can choose to have CloudTrail publish Amazon SNS notifications when new log files are delivered if you want to take quick action upon log file delivery\. For more information, see [Configuring Amazon SNS notifications for CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/configure-sns-notifications-for-cloudtrail.html)\. You can also aggregate AWS Lambda log files from multiple AWS regions and multiple AWS accounts into a single S3 bucket\. For more information, see [Working with CloudTrail log files](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-working-with-log-files.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
db6c5bc8bb13-0
CloudTrail log files contain one or more log entries where each entry is made up of multiple JSON\-formatted events\. A log entry represents a single request from any source and includes information about the requested action, any parameters, the date and time of the action, and so on\. The log entries are not guaranteed to be in any particular order\. That is, they are not an ordered stack trace of the public API calls\. The following example shows CloudTrail log entries for the `GetFunction` and `DeleteFunction` actions\. ``` { "Records": [ { "eventVersion": "1.03", "userIdentity": { "type": "IAMUser", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "arn": "arn:aws:iam::999999999999:user/myUserName", "accountId": "999999999999", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "myUserName" }, "eventTime": "2015-03-18T19:03:36Z", "eventSource": "lambda.amazonaws.com", "eventName": "GetFunction", "awsRegion": "us-east-1",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
db6c5bc8bb13-1
"eventName": "GetFunction", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "Python-httplib2/0.8 (gzip)", "errorCode": "AccessDenied", "errorMessage": "User: arn:aws:iam::999999999999:user/myUserName is not authorized to perform: lambda:GetFunction on resource: arn:aws:lambda:us-west-2:999999999999:function:other-acct-function", "requestParameters": null, "responseElements": null, "requestID": "7aebcd0f-cda1-11e4-aaa2-e356da31e4ff", "eventID": "e92a3e85-8ecd-4d23-8074-843aabfe89bf", "eventType": "AwsApiCall", "recipientAccountId": "999999999999" }, { "eventVersion": "1.03", "userIdentity": { "type": "IAMUser",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
db6c5bc8bb13-2
"eventVersion": "1.03", "userIdentity": { "type": "IAMUser", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "arn": "arn:aws:iam::999999999999:user/myUserName", "accountId": "999999999999", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "myUserName" }, "eventTime": "2015-03-18T19:04:42Z", "eventSource": "lambda.amazonaws.com", "eventName": "DeleteFunction", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "Python-httplib2/0.8 (gzip)", "requestParameters": { "functionName": "basic-node-task" }, "responseElements": null, "requestID": "a2198ecc-cda1-11e4-aaa2-e356da31e4ff",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
db6c5bc8bb13-3
"requestID": "a2198ecc-cda1-11e4-aaa2-e356da31e4ff", "eventID": "20b84ce5-730f-482e-b2b2-e8fcc87ceb22", "eventType": "AwsApiCall", "recipientAccountId": "999999999999" } ] } ``` **Note** The `eventName` may include date and version information, such as `"GetFunction20150331"`, but it is still referring to the same public API\. For more information, see [ Services supported by CloudTrail event history](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events-supported-services.html#view-cloudtrail-events-supported-apis-lambda) in the *AWS CloudTrail User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
d061478a367a-0
CloudTrail also logs data events\. You can turn on data event logging so that you log an event every time Lambda functions are invoked\. This helps you understand what identities are invoking the functions and the frequency of their invocations\. For more information on this option, see [ Logging data events for trails](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
e6e77a16fb48-0
One data event that can be encountered is a `LambdaESMDisabled` event\. There are five general categories of error that are associated with this event: **`RESOURCE_NOT_FOUND`** The resource specified in the request does not exist\. **`FUNCTION_NOT_FOUND`** The function attached to the event source does not exist\. **`REGION_NAME_NOT_VALID`** A Region name provided to the event source or function is invalid\. **`AUTHORIZATION_ERROR`** Permissions have not been set, or are misconfigured\. **`FUNCTION_IN_FAILED_STATE`** The function code does not compile, has encountered an unrecoverable exception, or a bad deployment has occurred\. These errors are included in the CloudTrail event message within the `serviceEventDetails` entity\. **Example `serviceEventDetails` entity** ``` "serviceEventDetails":{ "ESMDisableReason":"Lambda Function not found" } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/logging-using-cloudtrail.md
dc50a853859a-0
All work in your Step Functions state machine is done by [https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html)\. A `Task` performs work by using an activity, a Lambda function, or by passing parameters to the API actions of other [Supported AWS Service Integrations for Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html)\. **Topics** + [Configuring a Lambda function as a task](#services-stepfunctions-task) + [Configuring a state machine as an event source](#services-stepfunctions-setup) + [Handling function and service errors](#services-stepfunctions-exceptions) + [AWS CloudFormation and AWS SAM](#services-stepfunctions-cloudformation)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
755284348173-0
Step Functions can invoke Lambda functions directly from a `Task` state in an [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) definition\. ``` ... "MyStateName":{ "Type":"Task", "Resource":"arn:aws:lambda:us-west-2:01234567890:function:my_lambda_function", "End":true ... ``` You can create a `Task` state that invokes your Lambda function with the input to the state machine or any JSON document\. **Example [event\.json](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/error-processor/event.json) – Input to [random\-error function](samples-errorprocessor.md)** ``` { "max-depth": 10, "current-depth": 0, "error-rate": 0.05 } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
14202cd5560c-0
You can create a Step Functions state machine that invokes a Lambda function\. The following example shows a `Task` state that invokes version `1` of a function named `my-function` with an event payload that has three keys\. When the function returns a successful response, the state machine continues to the next task\. **Example state machine** ``` ... "Invoke": { "Type": "Task", "Resource": "arn:aws:states:::lambda:invoke", "Parameters": { "FunctionName": "arn:aws:lambda:us-east-2:123456789012:function:my-function:1", "Payload": { "max-depth": 10, "current-depth": 0, "error-rate": 0.05 } }, "Next": "NEXT_STATE", "TimeoutSeconds": 25 } ``` **Permissions**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
14202cd5560c-1
"TimeoutSeconds": 25 } ``` **Permissions** Your state machine needs permission to call the Lambda API to invoke a function\. To grant it permission, add the AWS managed policy [AWSLambdaRole](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/service-role/AWSLambdaRole) or a function\-scoped inline policy to its role\. For more information, see [How AWS Step Functions Works with IAM](https://docs.aws.amazon.com/step-functions/latest/dg/procedure-create-iam-role.html) in the *AWS Step Functions Developer Guide*\. The `FunctionName` and `Payload` parameters map to parameters in the [Invoke](API_Invoke.md) API operation\. In addition to these, you can also specify the `InvocationType` and `ClientContext` parameters\. For example, to invoke the function asynchronously and continue to the next state without waiting for a result, you can set `InvocationType` to `Event`: ``` "InvocationType": "Event" ``` Instead of hard\-coding the event payload in the state machine definition, you can use the input from the state machine execution\. The following example uses the input specified when you run the state machine as the event payload: ``` "Payload.$": "$"
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
14202cd5560c-2
``` "Payload.$": "$" ``` You can also invoke a function asynchronously and wait for it to make a callback with the AWS SDK\. To do this, set the state's resource to `arn:aws:states:::lambda:invoke.waitForTaskToken`\. For more information, see [Invoke Lambda with Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html) in the *AWS Step Functions Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
b3ac1160627a-0
When your function or the Lambda service returns an error, you can retry the invocation or continue to a different state based on the error type\. The following example shows an invoke task that retries on `5XX` series Lambda API exceptions \(`ServiceException`\), throttles \(`TooManyRequestsException`\), runtime errors \(`Lambda.Unknown`\), and a function\-defined error named `function.MaxDepthError`\. It also catches an error named `function.DoublesRolledError` and continues to a state named `CaughtException` when it occurs\. **Example catch and retry pattern** ``` ... "Invoke": { "Type": "Task", "Resource": "arn:aws:states:::lambda:invoke", "Retry": [ { "ErrorEquals": [ "function.MaxDepthError", "Lambda.TooManyRequestsException", "Lambda.ServiceException", "Lambda.Unknown" ], "MaxAttempts": 5 } ], "Catch": [ { "ErrorEquals": [ "function.DoublesRolledError" ], "Next": "CaughtException" } ],
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
b3ac1160627a-1
"Next": "CaughtException" } ], "Parameters": { "FunctionName": "arn:aws:lambda:us-east-2:123456789012:function:my-function:1", ... ``` To catch or retry function errors, create a custom error type\. The name of the error type must match the `errorType` in the formatted error response that Lambda returns when you throw an error\. For more information on error handling in Step Functions, see [Handling Error Conditions Using a Step Functions State Machine](https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-handling-error-conditions.html) in the *AWS Step Functions Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
b7ca59c6ab3b-0
You can define state machines using a AWS CloudFormation template with AWS Serverless Application Model \(AWS SAM\)\. Using AWS SAM, you can define the state machine inline in the template or in a separate file\. The following example shows a state machine that invokes a Lambda function that handles errors\. It refers to a function resource defined in the same template \(not shown\)\. **Example branching pattern in template\.yml** ``` AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: An AWS Lambda application that uses AWS Step Functions. Resources: statemachine: Type: AWS::Serverless::StateMachine Properties: DefinitionSubstitutions: FunctionArn: !GetAtt function.Arn Payload: | { "max-depth": 5, "current-depth": 0, "error-rate": 0.2 } Definition: StartAt: Invoke States: Invoke: Type: Task Resource: arn:aws:states:::lambda:invoke Parameters: FunctionName: "${FunctionArn}" Payload: "${Payload}" InvocationType: Event Retry:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
b7ca59c6ab3b-1
Payload: "${Payload}" InvocationType: Event Retry: - ErrorEquals: - function.MaxDepthError - function.MaxDepthError - Lambda.TooManyRequestsException - Lambda.ServiceException - Lambda.Unknown IntervalSeconds: 1 MaxAttempts: 5 Catch: - ErrorEquals: - function.DoublesRolledError Next: CaughtException - ErrorEquals: - States.ALL Next: UncaughtException Next: Success CaughtException: Type: Pass Result: The function returned an error. End: true UncaughtException: Type: Pass Result: Invocation failed. End: true Success: Type: Pass Result: Invocation succeeded! End: true Events: scheduled: Type: Schedule Properties: Description: Run every minute Schedule: rate(1 minute) Type: STANDARD Policies: - AWSLambdaRole ... ``` This creates a state machine with the following structure:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
b7ca59c6ab3b-2
- AWSLambdaRole ... ``` This creates a state machine with the following structure: ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/services-stepfunctions-statemachine.png) For more information, see [AWS::Serverless::StateMachine](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html) in the *AWS Serverless Application Model Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-stepfunctions.md
4080c7a2da90-0
Use the following information to help you diagnose and fix common issues that you might encounter when working with Lambda and IAM\. **Topics** + [I am not authorized to perform an action in Lambda](#security_iam_troubleshoot-no-permissions) + [I am not authorized to perform iam:PassRole](#security_iam_troubleshoot-passrole) + [I want to view my access keys](#security_iam_troubleshoot-access-keys) + [I'm an administrator and want to allow others to access Lambda](#security_iam_troubleshoot-admin-delegate) + [I want to allow people outside of my AWS account to access my Lambda resources](#security_iam_troubleshoot-cross-account-access)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
c80d08624dec-0
If the AWS Management Console tells you that you're not authorized to perform an action, then you must contact your administrator for assistance\. Your administrator is the person that provided you with your user name and password\. The following example error occurs when the `mateojackson` IAM user tries to use the console to view details about a function but does not have `lambda:GetFunction` permissions\. ``` User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: lambda:GetFunction on resource: my-function ``` In this case, Mateo asks his administrator to update his policies to allow him to access the `my-function` resource using the `lambda:GetFunction` action\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
ccc4f52749f3-0
If you receive an error that you're not authorized to perform the `iam:PassRole` action, then you must contact your administrator for assistance\. Your administrator is the person that provided you with your user name and password\. Ask that person to update your policies to allow you to pass a role to Lambda\. Some AWS services allow you to pass an existing role to that service, instead of creating a new service role or service\-linked role\. To do this, you must have permissions to pass the role to the service\. The following example error occurs when an IAM user named `marymajor` tries to use the console to perform an action in Lambda\. However, the action requires the service to have permissions granted by a service role\. Mary does not have permissions to pass the role to the service\. ``` User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole ``` In this case, Mary asks her administrator to update her policies to allow her to perform the `iam:PassRole` action\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
cff317a6336d-0
After you create your IAM user access keys, you can view your access key ID at any time\. However, you can't view your secret access key again\. If you lose your secret key, you must create a new access key pair\. Access keys consist of two parts: an access key ID \(for example, `AKIAIOSFODNN7EXAMPLE`\) and a secret access key \(for example, `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`\)\. Like a user name and password, you must use both the access key ID and secret access key together to authenticate your requests\. Manage your access keys as securely as you do your user name and password\. **Important** Do not provide your access keys to a third party, even to help [find your canonical user ID](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html#FindingCanonicalId)\. By doing this, you might give someone permanent access to your account\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
cff317a6336d-1
When you create an access key pair, you are prompted to save the access key ID and secret access key in a secure location\. The secret access key is available only at the time you create it\. If you lose your secret access key, you must add new access keys to your IAM user\. You can have a maximum of two access keys\. If you already have two, you must delete one key pair before creating a new one\. To view instructions, see [Managing Access Keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
fb19caa85ef3-0
To allow others to access Lambda, you must create an IAM entity \(user or role\) for the person or application that needs access\. They will use the credentials for that entity to access AWS\. You must then attach a policy to the entity that grants them the correct permissions in Lambda\. To get started right away, see [Creating Your First IAM Delegated User and Group](https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-delegated-user.html) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
dad4c56cd4d0-0
You can create a role that users in other accounts or people outside of your organization can use to access your resources\. You can specify who is trusted to assume the role\. For services that support resource\-based policies or access control lists \(ACLs\), you can use those policies to grant people access to your resources\. To learn more, consult the following: + To learn whether Lambda supports these features, see [How AWS Lambda works with IAM](security_iam_service-with-iam.md)\. + To learn how to provide access to your resources across AWS accounts that you own, see [Providing Access to an IAM User in Another AWS Account That You Own](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html) in the *IAM User Guide*\. + To learn how to provide access to your resources to third\-party AWS accounts, see [Providing Access to AWS Accounts Owned by Third Parties](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) in the *IAM User Guide*\. + To learn how to provide access through identity federation, see [Providing Access to Externally Authenticated Users \(Identity Federation\)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_federated-users.html) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
dad4c56cd4d0-1
+ To learn the difference between using roles and resource\-based policies for cross\-account access, see [How IAM Roles Differ from Resource\-based Policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_compare-resource-policies.html) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_troubleshoot.md
4b4cae247f56-0
Returns information about the function or function version, with a link to download the deployment package that's valid for 10 minutes\. If you specify a function version, only details that are specific to that version are returned\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
5dd0c679c8ab-0
``` GET /2015-03-31/functions/FunctionName?Qualifier=Qualifier HTTP/1.1 ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
3eb0e1a7dbdc-0
The request uses the following URI parameters\. ** [FunctionName](#API_GetFunction_RequestSyntax) ** <a name="SSS-GetFunction-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 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: Yes
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
3eb0e1a7dbdc-1
Required: Yes ** [Qualifier](#API_GetFunction_RequestSyntax) ** <a name="SSS-GetFunction-request-Qualifier"></a> Specify a version or alias to get details about a published version of the function\. 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_GetFunction.md
18380aea9640-0
The request does not have a request body\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
0aa74dabbcd9-0
``` HTTP/1.1 200 Content-type: application/json { "Code": { "Location": "string", "RepositoryType": "string" }, "Concurrency": { "ReservedConcurrentExecutions": number }, "Configuration": { "CodeSha256": "string", "CodeSize": number, "DeadLetterConfig": { "TargetArn": "string" }, "Description": "string", "Environment": { "Error": { "ErrorCode": "string", "Message": "string" }, "Variables": { "string" : "string" } }, "FileSystemConfigs": [ { "Arn": "string", "LocalMountPath": "string" } ], "FunctionArn": "string", "FunctionName": "string", "Handler": "string", "KMSKeyArn": "string", "LastModified": "string",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
0aa74dabbcd9-1
"Handler": "string", "KMSKeyArn": "string", "LastModified": "string", "LastUpdateStatus": "string", "LastUpdateStatusReason": "string", "LastUpdateStatusReasonCode": "string", "Layers": [ { "Arn": "string", "CodeSize": number } ], "MasterArn": "string", "MemorySize": number, "RevisionId": "string", "Role": "string", "Runtime": "string", "State": "string", "StateReason": "string", "StateReasonCode": "string", "Timeout": number, "TracingConfig": { "Mode": "string" }, "Version": "string", "VpcConfig": { "SecurityGroupIds": [ "string" ], "SubnetIds": [ "string" ], "VpcId": "string" } }, "Tags": { "string" : "string" } }
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
0aa74dabbcd9-2
} }, "Tags": { "string" : "string" } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
f8f3ca5e6d85-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\. ** [Code](#API_GetFunction_ResponseSyntax) ** <a name="SSS-GetFunction-response-Code"></a> The deployment package of the function or version\. Type: [FunctionCodeLocation](API_FunctionCodeLocation.md) object ** [Concurrency](#API_GetFunction_ResponseSyntax) ** <a name="SSS-GetFunction-response-Concurrency"></a> The function's [reserved concurrency](https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html)\. Type: [Concurrency](API_Concurrency.md) object ** [Configuration](#API_GetFunction_ResponseSyntax) ** <a name="SSS-GetFunction-response-Configuration"></a> The configuration of the function or version\. Type: [FunctionConfiguration](API_FunctionConfiguration.md) object ** [Tags](#API_GetFunction_ResponseSyntax) ** <a name="SSS-GetFunction-response-Tags"></a> The function's [tags](https://docs.aws.amazon.com/lambda/latest/dg/tagging.html)\. Type: String to string map
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
bfa30b7c4ae5-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_GetFunction.md
13a7c8a7abae-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/GetFunction) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/GetFunction) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/GetFunction) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/GetFunction) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/GetFunction) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/GetFunction) + [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/GetFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
13a7c8a7abae-1
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/GetFunction) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/GetFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetFunction.md
983b2e216c11-0
The following sections explain how common programming patterns and core concepts apply when you author Lambda function code in PowerShell\. **\.NET runtimes** | Name | Identifier | Operating system | | --- | --- | --- | | \.NET Core 3\.1 | `dotnetcore3.1` | Amazon Linux 2 | | \.NET Core 2\.1 | `dotnetcore2.1` | Amazon Linux | **Note** To get started with application development in your local environment, deploy one of the sample applications available in this guide's GitHub repository\. [blank\-powershell](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-powershell) – A PowerShell function that shows the use of logging, environment variables, and the AWS SDK\. Before you get started, you must first set up a PowerShell development environment\. For instructions on how to do this, see [Setting Up a PowerShell Development Environment](powershell-devenv.md)\. To learn about how to use the AWSLambdaPSCore module to download sample PowerShell projects from templates, create PowerShell deployment packages, and deploy PowerShell functions to the AWS Cloud, see [AWS Lambda deployment package in PowerShell](powershell-package.md)\. **Topics** + [Setting Up a PowerShell Development Environment](powershell-devenv.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-powershell.md
983b2e216c11-1
**Topics** + [Setting Up a PowerShell Development Environment](powershell-devenv.md) + [AWS Lambda deployment package in PowerShell](powershell-package.md) + [AWS Lambda function handler in PowerShell](powershell-handler.md) + [AWS Lambda context object in PowerShell](powershell-context.md) + [AWS Lambda function logging in PowerShell](powershell-logging.md) + [AWS Lambda function errors in PowerShell](powershell-exceptions.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-powershell.md
2acd9f818f7d-0
You can use a Lambda function to process requests from an Application Load Balancer\. Elastic Load Balancing supports Lambda functions as a target for an Application Load Balancer\. Use load balancer rules to route HTTP requests to a function, based on path or header values\. Process the request and return an HTTP response from your Lambda function\. Elastic Load Balancing invokes your Lambda function synchronously with an event that contains the request body and metadata\. **Example Application Load Balancer request event** ``` { "requestContext": { "elb": { "targetGroupArn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a" } }, "httpMethod": "GET", "path": "/lambda", "queryStringParameters": { "query": "1234ABCD" }, "headers": { "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "accept-encoding": "gzip", "accept-language": "en-US,en;q=0.9",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-alb.md
2acd9f818f7d-1
"accept-encoding": "gzip", "accept-language": "en-US,en;q=0.9", "connection": "keep-alive", "host": "lambda-alb-123578498.us-east-2.elb.amazonaws.com", "upgrade-insecure-requests": "1", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "x-amzn-trace-id": "Root=1-5c536348-3d683b8b04734faae651f476", "x-forwarded-for": "72.12.164.125", "x-forwarded-port": "80", "x-forwarded-proto": "http", "x-imforwards": "20" }, "body": "", "isBase64Encoded": false } ``` Your function processes the event and returns a response document to the load balancer in JSON\. Elastic Load Balancing converts the document to an HTTP success or error response and returns it to the user\. **Example response document format** ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-alb.md
2acd9f818f7d-2
**Example response document format** ``` { "statusCode": 200, "statusDescription": "200 OK", "isBase64Encoded": False, "headers": { "Content-Type": "text/html" }, "body": "<h1>Hello from Lambda!</h1>" } ``` To configure an Application Load Balancer as a function trigger, grant Elastic Load Balancing permission to execute the function, create a target group that routes requests to the function, and add a rule to the load balancer that sends requests to the target group\. Use the `add-permission` command to add a permission statement to your function's resource\-based policy\. ``` $ aws lambda add-permission --function-name alb-function \ --statement-id load-balancer --action "lambda:InvokeFunction" \ --principal elasticloadbalancing.amazonaws.com {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-alb.md
2acd9f818f7d-3
--principal elasticloadbalancing.amazonaws.com { "Statement": "{\"Sid\":\"load-balancer\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"elasticloadbalancing.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-west-2:123456789012:function:alb-function\"}" } ``` For instructions on configuring the Application Load Balancer listener and target group, see [Lambda functions as a target](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html) in the *User Guide for Application Load Balancers*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-alb.md
7e3d0e35ad95-0
An AWS Lambda application is a combination of Lambda functions, event sources, and other resources that work together to perform tasks\. You can use AWS CloudFormation and other tools to collect your application's components into a single package that can be deployed and managed as one resource\. Applications make your Lambda projects portable and enable you to integrate with additional developer tools, such as AWS CodePipeline, AWS CodeBuild, and the AWS Serverless Application Model command line interface \(SAM CLI\)\. The [AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/) provides a collection of Lambda applications that you can deploy in your account with a few clicks\. The repository includes both ready\-to\-use applications and samples that you can use as a starting point for your own projects\. You can also submit your own projects for inclusion\. [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-concepts.html) enables you to create a template that defines your application's resources and lets you manage the application as a *stack*\. You can more safely add or modify resources in your application stack\. If any part of an update fails, AWS CloudFormation automatically rolls back to the previous configuration\. With AWS CloudFormation parameters, you can create multiple environments for your application from the same template\. [AWS SAM](gettingstarted-tools.md#gettingstarted-tools-awssam) extends AWS CloudFormation with a simplified syntax focused on Lambda application development\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/deploying-lambda-apps.md
7e3d0e35ad95-1
The [AWS CLI](gettingstarted-tools.md#gettingstarted-tools-awscli) and [SAM CLI](gettingstarted-tools.md#gettingstarted-tools-samcli) are command line tools for managing Lambda application stacks\. In addition to commands for managing application stacks with the AWS CloudFormation API, the AWS CLI supports higher\-level commands that simplify tasks like uploading deployment packages and updating templates\. The AWS SAM CLI provides additional functionality, including validating templates and testing locally\. **Topics** + [Managing applications in the AWS Lambda console](applications-console.md) + [Creating an application with continuous delivery in the Lambda console](applications-tutorial.md) + [Rolling deployments for Lambda functions](lambda-rolling-deployments.md) + [Common Lambda application types and use cases](applications-usecases.md) + [Best practices for working with AWS Lambda functions](best-practices.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/deploying-lambda-apps.md
2fe4757f045d-0
You can build \.NET\-based Lambda applications using the Lambda plugin to the [AWS Toolkit for Visual Studio](https://aws.amazon.com/visualstudio/)\. The toolkit is available as a [Visual Studio extension](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017)\. 1. Launch Microsoft Visual Studio and choose **New project**\. 1. From the **File** menu, choose **New**, and then choose **Project**\. 1. In the **New Project** window, choose **AWS Lambda Project \(\.NET Core\)** and then choose **OK**\. 1. In the **Select Blueprint** window, you will be presented with the option of selecting from a list of sample applications that will provide you with sample code to get started with creating a \.NET\-based Lambda application\. 1. To create a Lambda application from scratch, choose **Empty Function** and then choose **Finish**\. 1. Examine the `aws-lambda-tools-defaults.json` file, which is created as part of your project\. You can set the options in this file, which is read by the Lambda tooling by default\. The project templates created in Visual Studio set many of these fields with default values\. Note the following fields:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/csharp-package-toolkit.md
2fe4757f045d-1
+ **profile** – The name of a profile in your [AWS SDK for \.NET credentials file](https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html)\. + **function\-handler** – This is where the `function handler` is specified, which is why you don't have to set it in the wizard\. However, whenever you rename the *Assembly*, *Namespace*, *Class* or *Function* in your function code, you will need to update the corresponding fields in the `aws-lambda-tools-defaults.json file`\. ``` { "profile":"default", "region" : "us-east-2", "configuration" : "Release", "framework" : "netcoreapp2.1", "function-runtime":"dotnetcore3.1", "function-memory-size" : 256, "function-timeout" : 30, "function-handler" : "Assembly::Namespace.Class::Function" } ``` 1. Open the **Function\.cs** file\. You will be provided with a template to implement your Lambda function handler code\. ![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/lambda-function.png)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/csharp-package-toolkit.md
2fe4757f045d-2
1. Once you have written the code that represents your Lambda function, you can upload it by right\-clicking the **Project** node in your application and then choosing **Publish to AWS Lambda**\. 1. In the **Upload Lambda Function** window, type a name for the function or select a previously published function to republish\. Then choose **Next** 1. In the **Advanced Function Details** window, configure the following options: + **Role Name** \(required\) – The [IAM role](lambda-intro-execution-role.md) that AWS Lambda assumes when it executes your function\. + **Environment** – Key\-value pairs that Lambda sets in the execution environment\. [ Use environment variables](configuration-envvars.md) to extend your function's configuration outside of code\. + **Memory** – The amount of memory available to the function during execution\. Choose an amount [between 128 MB and 3,008 MB](gettingstarted-limits.md) in 64\-MB increments\. + **Timeout** – The amount of time that Lambda allows a function to run before stopping it\. The default is 3 seconds\. The maximum allowed value is 900 seconds\. + **VPC** – If your function needs network access to resources that are not available over the internet, [configure it to connect to a VPC](configuration-vpc.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/csharp-package-toolkit.md
2fe4757f045d-3
+ **DLQ** – If your function is invoked asynchronously, [choose a queue or topic](invocation-async.md#dlq) to receive failed invocations\. + **Enable active tracing** – Sample incoming requests and [trace sampled requests with AWS X\-Ray](services-xray.md)\. 1. Choose **Next** and then choose **Upload** to deploy your application\. For more information, see [Deploying an AWS Lambda Project with the \.NET Core CLI](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-cli-publish.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/csharp-package-toolkit.md
a4f9f1d45ab0-0
The VPC security groups and subnets that are attached to a Lambda function\. For more information, see [VPC Settings](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_VpcConfig.md