id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
c287dd11345e-5
+ [Asynchronous invocation](invocation-async.md) + [AWS Lambda event source mappings](invocation-eventsourcemapping.md) + [Error handling and automatic retries in AWS Lambda](invocation-retries.md) + [Using AWS Lambda with other services](lambda-services.md) You can monitor concurrency levels in your account by using the following metrics: **Concurrency metrics** + `ConcurrentExecutions` + `UnreservedConcurrentExecutions` + `ProvisionedConcurrentExecutions` + `ProvisionedConcurrencyInvocations` + `ProvisionedConcurrencySpilloverInvocations` + `ProvisionedConcurrencyUtilization` For more information, see [Working with AWS Lambda function metrics](monitoring-metrics.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/invocation-scaling.md
268653a9ab9b-0
**DestinationConfig** <a name="SSS-Type-FunctionEventInvokeConfig-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 **FunctionArn** <a name="SSS-Type-FunctionEventInvokeConfig-FunctionArn"></a> 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-_]+))?` Required: No
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionEventInvokeConfig.md
268653a9ab9b-1
Required: No **LastModified** <a name="SSS-Type-FunctionEventInvokeConfig-LastModified"></a> The date and time that the configuration was last updated, in Unix time seconds\. Type: Timestamp Required: No **MaximumEventAgeInSeconds** <a name="SSS-Type-FunctionEventInvokeConfig-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 **MaximumRetryAttempts** <a name="SSS-Type-FunctionEventInvokeConfig-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_FunctionEventInvokeConfig.md
971417c93d78-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/FunctionEventInvokeConfig) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/FunctionEventInvokeConfig) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/FunctionEventInvokeConfig) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/FunctionEventInvokeConfig)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_FunctionEventInvokeConfig.md
a807ec7eef3a-0
You can tag Lambda functions to organize them by owner, project or department\. Tags are freeform key\-value pairs that are supported across AWS services for use in filtering resources and adding detail to billing reports\. **To add tags to a function** 1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\. 1. Choose a function\. 1. Under **Tags**, choose **Manage tags**\. 1. Enter a key and value\. To add additional tags, choose **Add new tag**\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/configuration-tags-add.png) 1. Choose **Save**\. You can filter functions based on the presence or value of a tag with the Lambda console or with the AWS Resource Groups API\. Tags apply at the function level, not to versions or aliases\. Tags are not part of the version\-specific configuration that is snapshotted when you publish a version\. **To filter functions with tags** 1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\. 1. Click within the search bar to see a list of function attributes and tag keys\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
a807ec7eef3a-1
1. Click within the search bar to see a list of function attributes and tag keys\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/configuration-tags-key.png) 1. Choose a tag key to see a list of values that are in\-use in the current region\. 1. Choose a value to see functions with that value, or choose **\(all values\)** to see all functions that have a tag with that key\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/configuration-tags-value.png) The search bar also supports searching for tag keys\. Type `tag` to see just a list of tag keys, or start typing the name of a key to find it in the list\. With AWS Billing and Cost Management, you can use tags to customize billing reports and create cost\-allocation reports\. For more information, see see [Monthly Cost Allocation Report](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/configurecostallocreport.html) and [Using Cost Allocation Tags](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html) in the *AWS Billing and Cost Management User Guide*\. **Topics** + [Using Tags with the AWS CLI](#configuration-tags-cli)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
a807ec7eef3a-2
**Topics** + [Using Tags with the AWS CLI](#configuration-tags-cli) + [Tag Key and Value Requirements](#configuration-tags-restrictions)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
835b0b78f785-0
When you create a new Lambda function, you can include tags with the `--tags` option\. ``` $ aws lambda create-function --function-name my-function --handler index.js --runtime nodejs12.x \ --role arn:aws:iam::123456789012:role/lambda-role \ --tags Department=Marketing,CostCenter=1234ABCD ``` To add tags to an existing function, use the `tag-resource` command\. ``` $ aws lambda tag-resource \ --resource arn:aws:lambda:us-east-2:123456789012:function:my-function \ --tags Department=Marketing,CostCenter=1234ABCD ``` To remove tags, use the `untag-resource` command\. ``` $ aws lambda untag-resource --resource function arn \ --tag-keys Department ``` If you want to view the tags that are applied to a specific Lambda function, you can use either of the following Lambda API commands: + [ListTags](API_ListTags.md) – You supply your Lambda function ARN \(Amazon Resource Name\) to view a list of the tags associated with this function: ``` $ aws lambda list-tags --resource function arn ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
835b0b78f785-1
``` $ aws lambda list-tags --resource function arn ``` + [GetFunction](API_GetFunction.md) – You supply your Lambda function name to a view a list of the tags associated with this function: ``` $ aws lambda get-function --function-name my-function ``` You can also use the AWS Tagging Service’s [GetResources](https://docs.aws.amazon.com/resourcegroupstagging/latest/APIReference/API_GetResources.html) API to filter your resources by tags\. The GetResources API receives up to 10 filters, with each filter containing a tag key and up to 10 tag values\. You provide GetResources with a ‘ResourceType’ to filter by specific resource types\. For more information about the AWS Tagging Service, see [Working with Resource Groups](https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/resource-groups.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
780715ae570c-0
The following requirements apply to tags: + Maximum number of tags per resource—50 + Maximum key length—128 Unicode characters in UTF\-8 + Maximum value length—256 Unicode characters in UTF\-8 + Tag keys and values are case sensitive\. + Do not use the `aws:` prefix in your tag names or values because it is reserved for AWS use\. You can't edit or delete tag names or values with this prefix\. Tags with this prefix do not count against your tags per resource limit\. + If your tagging schema will be used across multiple services and resources, remember that other services may have restrictions on allowed characters\. Generally allowed characters are: letters, spaces, and numbers representable in UTF\-8, plus the following special characters: \+ \- = \. \_ : / @\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/configuration-tags.md
3c4026ecd628-0
The following sections explain how common programming patterns and core concepts apply when authoring Lambda function code in [Go](https://golang.org/)\. **Go runtimes** | Name | Identifier | Operating system | | --- | --- | --- | | Go 1\.x | `go1.x` | Amazon Linux | AWS Lambda provides the following libraries for Go: + **github\.com/aws/aws\-lambda\-go/lambda**: The implementation of the Lambda programming model for Go\. This package is used by AWS Lambda to invoke your [handler](golang-handler.md)\. + **github\.com/aws/aws\-lambda\-go/lambdacontext**: Helpers for accessing execution context information from the [context object](golang-context.md)\. + **github\.com/aws/aws\-lambda\-go/events**: This library provides type definitions for common event source integrations\. **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\-go](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-go) – A Go function that shows the use of Lambda's Go libraries, logging, environment variables, and the AWS SDK\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-golang.md
3c4026ecd628-1
**Topics** + [AWS Lambda deployment package in Go](golang-package.md) + [AWS Lambda function handler in Go](golang-handler.md) + [AWS Lambda context object in Go](golang-context.md) + [AWS Lambda function logging in Go](golang-logging.md) + [AWS Lambda function errors in Go](golang-exceptions.md) + [Instrumenting Go code in AWS Lambda](golang-tracing.md) + [Using environment variables](golang-envvars.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-golang.md
072209e2d65d-0
You can run Java code in AWS Lambda\. Lambda provides [runtimes](lambda-runtimes.md) for Java that execute your code to process events\. Your code runs in an Amazon Linux environment that includes AWS credentials from an AWS Identity and Access Management \(IAM\) role that you manage\. Lambda supports the following Java runtimes\. **Java runtimes** | Name | Identifier | JDK | Operating system | | --- | --- | --- | --- | | Java 11 | `java11` | amazon\-corretto\-11 | Amazon Linux 2 | | Java 8 | `java8.al2` | amazon\-corretto\-8 | Amazon Linux 2 | | Java 8 | `java8` | java\-1\.8\.0\-openjdk | Amazon Linux | Lambda functions use an [execution role](lambda-intro-execution-role.md) to get permission to write logs to Amazon CloudWatch Logs, and to access other services and resources\. If you don't already have an execution role for function development, create one\. **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** – **Lambda**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-java.md
072209e2d65d-1
1. Create a role with the following properties\. + **Trusted entity** – **Lambda**\. + **Permissions** – **AWSLambdaBasicExecutionRole**\. + **Role name** – **lambda\-role**\. The **AWSLambdaBasicExecutionRole** policy has the permissions that the function needs to write logs to CloudWatch Logs\. You can add permissions to the role later, or swap it out for a different role that's specific to a single function\. **To create a Java function** 1. Open the [Lambda console](https://console.aws.amazon.com/lambda)\. 1. Choose **Create function**\. 1. Configure the following settings: + **Name** – **my\-function**\. + **Runtime** – **Java 11**\. + **Role** – **Choose an existing role**\. + **Existing role** – **lambda\-role**\. 1. Choose **Create function**\. 1. To configure a test event, choose **Test**\. 1. For **Event name**, enter **test**\. 1. Choose **Create**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-java.md
072209e2d65d-2
1. For **Event name**, enter **test**\. 1. Choose **Create**\. 1. To execute the function, choose **Test**\. The console creates a Lambda function with a handler class named `Hello`\. Since Java is a compiled language, you can't view or edit the source code in the Lambda console, but you can modify its configuration, invoke it, and configure triggers\. **Note** To get started with application development in your local environment, deploy one of the [sample applications](java-samples.md) available in this guide's GitHub repository\. The `Hello` class has a function named `handleRequest` that takes an event object and a context object\. This is the [handler function](java-handler.md) that Lambda calls when the function is invoked\. The Java function runtime gets invocation events from Lambda and passes them to the handler\. In the function configuration, the handler value is `example.Hello::handleRequest`\. To update the function's code, you create a deployment package, which is a ZIP archive that contains your function code\. As your function development progresses, you will want to store your function code in source control, add libraries, and automate deployments\. Start by [creating a deployment package](java-package.md) and updating your code at the command line\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-java.md
072209e2d65d-3
The function runtime passes a context object to the handler, in addition to the invocation event\. The [context object](java-context.md) contains additional information about the invocation, the function, and the execution environment\. More information is available from environment variables\. Your Lambda function comes with a CloudWatch Logs log group\. The function runtime sends details about each invocation to CloudWatch Logs\. It relays any [logs that your function outputs](java-logging.md) during invocation\. If your function [returns an error](java-exceptions.md), Lambda formats the error and returns it to the invoker\. **Topics** + [Java sample applications for AWS Lambda](java-samples.md) + [AWS Lambda deployment package in Java](java-package.md) + [AWS Lambda function handler in Java](java-handler.md) + [AWS Lambda context object in Java](java-context.md) + [AWS Lambda function logging in Java](java-logging.md) + [AWS Lambda function errors in Java](java-exceptions.md) + [Instrumenting Java code in AWS Lambda](java-tracing.md) + [Creating a deployment package using Eclipse](java-package-eclipse.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-java.md
0311584eb2e6-0
You can invoke Lambda functions directly [with the Lambda console](getting-started-create-function.md#get-started-invoke-manually), the Lambda API, the AWS SDK, the AWS CLI, and AWS toolkits\. You can also configure other AWS services to invoke your function, or you can configure Lambda to read from a stream or queue and invoke your function\. When you invoke a function, you can choose to invoke it synchronously or asynchronously\. With [synchronous invocation](invocation-sync.md), you wait for the function to process the event and return a response\. With [asynchronous](invocation-async.md) invocation, Lambda queues the event for processing and returns a response immediately\. For asynchronous invocation, Lambda handles retries and can send invocation records to a [destination](invocation-async.md#invocation-async-destinations)\. To use your function to process data automatically, add one or more triggers\. A trigger is a Lambda resource or a resource in another service that you configure to invoke your function in response to lifecycle events, external requests, or on a schedule\. Your function can have multiple triggers\. Each trigger acts as an client invoking your function independently\. Each event that Lambda passes to your function only has data from one client or trigger\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-invocation.md
0311584eb2e6-1
To process items from a stream or queue, you can create an [event source mapping](invocation-eventsourcemapping.md)\. An event source mapping is a resource in Lambda that reads items from an Amazon SQS queue, an Amazon Kinesis stream, or an Amazon DynamoDB stream, and sends them to your function in batches\. Each event that your function processes can contain hundreds or thousands of items\. Other AWS services and resources invoke your function directly\. For example, you can configure CloudWatch Events to invoke your function on a timer, or you can configure Amazon S3 to invoke your function when an object is created\. Each service varies in the method it uses to invoke your function, the structure of the event, and how you configure it\. For more information, see [Using AWS Lambda with other services](lambda-services.md)\. Depending on who invokes your function and how it's invoked, scaling behavior and the types of errors that occur can vary\. When you invoke a function synchronously, you receive errors in the response and can retry\. When you invoke asynchronously, use an event source mapping, or configure another service to invoke your function, the retry requirements and the way that your function scales to handle large numbers of events can vary\. For details, see [AWS Lambda function scaling](invocation-scaling.md) and [Error handling and automatic retries in AWS Lambda](invocation-retries.md)\. **Topics** + [Synchronous invocation](invocation-sync.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-invocation.md
0311584eb2e6-2
**Topics** + [Synchronous invocation](invocation-sync.md) + [Asynchronous invocation](invocation-async.md) + [AWS Lambda event source mappings](invocation-eventsourcemapping.md) + [Monitoring the state of a function with the Lambda API](functions-states.md) + [AWS Lambda function scaling](invocation-scaling.md) + [Error handling and automatic retries in AWS Lambda](invocation-retries.md) + [Invoking Lambda functions with the AWS Mobile SDK for Android](with-on-demand-custom-android.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-invocation.md
92c61a1dd1b0-0
Returns a list of [versions](https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html), with the version\-specific configuration of each\. Lambda returns up to 50 versions per call\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
9444dfc4b4b6-0
``` GET /2015-03-31/functions/FunctionName/versions?Marker=Marker&MaxItems=MaxItems HTTP/1.1 ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
0fe4a9d124cd-0
The request uses the following URI parameters\. ** [FunctionName](#API_ListVersionsByFunction_RequestSyntax) ** <a name="SSS-ListVersionsByFunction-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 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_ListVersionsByFunction.md
0fe4a9d124cd-1
Required: Yes ** [Marker](#API_ListVersionsByFunction_RequestSyntax) ** <a name="SSS-ListVersionsByFunction-request-Marker"></a> Specify the pagination token that's returned by a previous request to retrieve the next page of results\. ** [MaxItems](#API_ListVersionsByFunction_RequestSyntax) ** <a name="SSS-ListVersionsByFunction-request-MaxItems"></a> The maximum number of versions to return\. Valid Range: Minimum value of 1\. Maximum value of 10000\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
32db355afc2c-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_ListVersionsByFunction.md
15c81dda57b4-0
``` HTTP/1.1 200 Content-type: application/json { "NextMarker": "string", "Versions": [ { "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", "LastUpdateStatus": "string", "LastUpdateStatusReason": "string", "LastUpdateStatusReasonCode": "string", "Layers": [
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
15c81dda57b4-1
"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" } } ] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
ad322bd8e4f9-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\. ** [NextMarker](#API_ListVersionsByFunction_ResponseSyntax) ** <a name="SSS-ListVersionsByFunction-response-NextMarker"></a> The pagination token that's included if more results are available\. Type: String ** [Versions](#API_ListVersionsByFunction_ResponseSyntax) ** <a name="SSS-ListVersionsByFunction-response-Versions"></a> A list of Lambda function versions\. Type: Array of [FunctionConfiguration](API_FunctionConfiguration.md) objects
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
bdbfbef478c3-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_ListVersionsByFunction.md
b1b55137ffb7-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/ListVersionsByFunction) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/ListVersionsByFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
b1b55137ffb7-1
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/ListVersionsByFunction) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/ListVersionsByFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_ListVersionsByFunction.md
beb1467faf06-0
You can use the Lambda console to view details about your Step Functions state machines and the Lambda functions that they use\. **Topics** + [Viewing state machine details](#stepfunctions-configure) + [Editing a state machine](#stepfunctions-edit) + [Running a state machine](#stepfunctions-run)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/stepfunctions-lc.md
6cf334dec7ab-0
The Lambda console displays a list of your state machines in the current AWS Region that contain at least one workflow step that invokes a Lambda function\. Choose a state machine to view a graphical representation of the workflow\. Steps highlighted in blue represent Lambda functions\. Use the graph controls to zoom in, zoom out, and center the graph\. **Note** When a Lambda function is [dynamically referenced with JsonPath](https://docs.aws.amazon.com/step-functions/latest/dg/connect-parameters.html#connect-parameters-path) in the state machine definition, the function details cannot be shown in the Lambda console\. Instead, the function name is listed as a **Dynamic reference**, and the corresponding steps in the graph are grayed out\. **To view state machine details** 1. Open the Lambda console [Step Functions state machines page](https://console.aws.amazon.com/lambda/home#/stepfunctions)\. 1. Choose a state machine\. The Lambda console opens the **Details** page\. For more information, see [Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html) in the *AWS Step Functions Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/stepfunctions-lc.md
969eec442297-0
When you want to edit a state machine, Lambda opens the **Edit definition** page of the Step Functions console\. **To edit a state machine** 1. Open the Lambda console [Step Functions state machine page](https://console.aws.amazon.com/lambda/home#/functions)\. 1. Choose a state machine\. 1. Choose **Edit**\. The Step Functions console opens the **Edit definition** page\. 1. Edit the state machine and choose **Save**\. For more information about editing state machines, see [Step Functions state machine language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) in the *AWS Step Functions Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/stepfunctions-lc.md
04cd6b5b0860-0
When you want to run a state machine, Lambda opens the **New execution** page of the Step Functions console\. **To run a state machine** 1. Open the Lambda console [Step Functions state machines page](https://console.aws.amazon.com/lambda/home#/stepfunctions)\. 1. Choose a state machine\. 1. Choose **Execute**\. The Step Functions console opens the **New execution** page\. 1. \(Optional\) Edit the state machine and choose **Start execution**\. For more information about running state machines, see [Step Functions state machine execution concepts](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-executions.html) in the *AWS Step Functions Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/stepfunctions-lc.md
f64b0935f9b9-0
You can use a Lambda function to monitor and analyze logs from an Amazon CloudWatch Logs log stream\. Create [subscriptions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/Subscriptions.html) for one or more log streams to invoke a function when logs are created or match an optional pattern\. Use the function to send a notification or persist the log to a database or storage\. CloudWatch Logs invokes your function asynchronously with an event that contains log data\. The value of the data field is a Base64 encoded ZIP archive\. **Example Amazon CloudWatch Logs message event** ``` { "awslogs": { "data": "ewogICAgIm1lc3NhZ2VUeXBlIjogIkRBVEFfTUVTU0FHRSIsCiAgICAib3duZXIiOiAiMTIzNDU2Nzg5MDEyIiwKICAgICJsb2dHcm91cCI6I..." } } ``` When decoded and decompressed, the log data is a JSON document with the following structure\. **Example Amazon CloudWatch Logs message data \(decoded\)** ``` { "messageType": "DATA_MESSAGE", "owner": "123456789012", "logGroup": "/aws/lambda/echo-nodejs", "logStream": "2019/03/13/[$LATEST]94fa867e5374431291a7fc14e2f56ae7", "subscriptionFilters": [ "LambdaStream_cloudwatchlogs-node" ],
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-cloudwatchlogs.md
f64b0935f9b9-1
"subscriptionFilters": [ "LambdaStream_cloudwatchlogs-node" ], "logEvents": [ { "id": "34622316099697884706540976068822859012661220141643892546", "timestamp": 1552518348220, "message": "REPORT RequestId: 6234bffe-149a-b642-81ff-2e8e376d8aff\tDuration: 46.84 ms\tBilled Duration: 100 ms \tMemory Size: 192 MB\tMax Memory Used: 72 MB\t\n" } ] } ``` For a sample application that uses CloudWatch Logs as a trigger, 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/services-cloudwatchlogs.md
25c0a0d20dda-0
The following are recommended best practices for using AWS Lambda: **Topics** + [Function code](#function-code) + [Function configuration](#function-configuration) + [Metrics and alarms](#alarming-metrics) + [Working with streams](#stream-events)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
37dc81c22788-0
+ **Separate the Lambda handler from your core logic\.** This allows you to make a more unit\-testable function\. In Node\.js this may look like: ``` exports.myHandler = function(event, context, callback) { var foo = event.foo; var bar = event.bar; var result = MyLambdaFunction (foo, bar); callback(null, result); } function MyLambdaFunction (foo, bar) { // MyLambdaFunction logic here } ``` + **Take advantage of execution context reuse to improve the performance of your function\.** Initialize SDK clients and database connections outside of the function handler, and cache static assets locally in the `/tmp` directory\. Subsequent invocations processed by the same instance of your function can reuse these resources\. This saves execution time and cost\. To avoid potential data leaks across invocations, don’t use the execution context to store user data, events, or other information with security implications\. If your function relies on a mutable state that can’t be stored in memory within the handler, consider creating a separate function or separate versions of a function for each user\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
37dc81c22788-1
+ **Use a keep\-alive directive to maintain persistent connections\.** Lambda purges idle connections over time\. Attempting to reuse an idle connection when invoking a function will result in a connection error\. To maintain your persistent connection, use the keep\-alive directive associated with your runtime\. For an example, see [Reusing Connections with Keep\-Alive in Node\.js](https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html)\. + **Use [environment variables](configuration-envvars.md) to pass operational parameters to your function\.** For example, if you are writing to an Amazon S3 bucket, instead of hard\-coding the bucket name you are writing to, configure the bucket name as an environment variable\. + **Control the dependencies in your function's deployment package\. ** The AWS Lambda execution environment contains a number of libraries such as the AWS SDK for the Node\.js and Python runtimes \(a full list can be found here: [AWS Lambda runtimes](lambda-runtimes.md)\)\. To enable the latest set of features and security updates, Lambda will periodically update these libraries\. These updates may introduce subtle changes to the behavior of your Lambda function\. To have full control of the dependencies your function uses, package all of your dependencies with your deployment package\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
37dc81c22788-2
+ **Minimize your deployment package size to its runtime necessities\. ** This will reduce the amount of time that it takes for your deployment package to be downloaded and unpacked ahead of invocation\. For functions authored in Java or \.NET Core, avoid uploading the entire AWS SDK library as part of your deployment package\. Instead, selectively depend on the modules which pick up components of the SDK you need \(e\.g\. DynamoDB, Amazon S3 SDK modules and [Lambda core libraries](https://github.com/aws/aws-lambda-java-libs)\)\. + **Reduce the time it takes Lambda to unpack deployment packages** authored in Java by putting your dependency `.jar` files in a separate /lib directory\. This is faster than putting all your function’s code in a single jar with a large number of `.class` files\. See [AWS Lambda deployment package in Java](java-package.md) for instructions\. + **Minimize the complexity of your dependencies\.** Prefer simpler frameworks that load quickly on [execution context](runtimes-context.md) startup\. For example, prefer simpler Java dependency injection \(IoC\) frameworks like [Dagger](https://google.github.io/dagger/) or [Guice](https://github.com/google/guice), over more complex ones like [Spring Framework](https://github.com/spring-projects/spring-framework)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
37dc81c22788-3
+ **Avoid using recursive code** in your Lambda function, wherein the function automatically calls itself until some arbitrary criteria is met\. This could lead to unintended volume of function invocations and escalated costs\. If you do accidentally do so, set the function concurrent execution limit to `0` immediately to throttle all invocations to the function, while you update the code\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
1809aabb1135-0
+ **Performance testing your Lambda function** is a crucial part in ensuring you pick the optimum memory size configuration\. Any increase in memory size triggers an equivalent increase in CPU available to your function\. The memory usage for your function is determined per\-invoke and can be viewed in [AWS CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatchLogs.html)\. On each invoke a `REPORT:` entry will be made, as shown below: ``` REPORT RequestId: 3604209a-e9a3-11e6-939a-754dd98c7be3 Duration: 12.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB ``` By analyzing the `Max Memory Used:` field, you can determine if your function needs more memory or if you over\-provisioned your function's memory size\. + **Load test your Lambda function** to determine an optimum timeout value\. It is important to analyze how long your function runs so that you can better determine any problems with a dependency service that may increase the concurrency of the function beyond what you expect\. This is especially important when your Lambda function makes network calls to resources that may not handle Lambda's scaling\. + **Use most\-restrictive permissions when setting IAM policies\.** Understand the resources and operations your Lambda function needs, and limit the execution role to these permissions\. For more information, see [AWS Lambda permissions](lambda-permissions.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
1809aabb1135-1
+ **Be familiar with [AWS Lambda quotas](gettingstarted-limits.md)\.** Payload size, file descriptors and /tmp space are often overlooked when determining runtime resource limits\. + **Delete Lambda functions that you are no longer using\.** By doing so, the unused functions won't needlessly count against your deployment package size limit\. + **If you are using Amazon Simple Queue Service** as an event source, make sure the value of the function's expected execution time does not exceed the [Visibility Timeout](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) value on the queue\. This applies both to [CreateFunction](API_CreateFunction.md) and [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md)\. + In the case of **CreateFunction**, AWS Lambda will fail the function creation process\. + In the case of **UpdateFunctionConfiguration**, it could result in duplicate invocations of the function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
06e5104c23ec-0
+ **Use [Working with AWS Lambda function metrics](monitoring-metrics.md) and [ CloudWatch Alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html)** instead of creating or updating a metric from within your Lambda function code\. It's a much more efficient way to track the health of your Lambda functions, allowing you to catch issues early in the development process\. For instance, you can configure an alarm based on the expected duration of your Lambda function execution time in order to address any bottlenecks or latencies attributable to your function code\. + **Leverage your logging library and [AWS Lambda Metrics and Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/lam-metricscollected.html)** to catch app errors \(e\.g\. ERR, ERROR, WARNING, etc\.\)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
ddfbf9f67a59-0
+ **Test with different batch and record sizes **so that the polling frequency of each event source is tuned to how quickly your function is able to complete its task\. [BatchSize](API_CreateEventSourceMapping.md#SSS-CreateEventSourceMapping-request-BatchSize) controls the maximum number of records that can be sent to your function with each invoke\. A larger batch size can often more efficiently absorb the invoke overhead across a larger set of records, increasing your throughput\. By default, Lambda invokes your function as soon as records are available in the stream\. If the batch that Lambda reads from the stream only has one record in it, Lambda sends only one record to the function\. To avoid invoking the function with a small number of records, you can tell the event source to buffer records for up to five minutes by configuring a *batch window*\. Before invoking the function, Lambda continues to read records from the stream until it has gathered a full batch, or until the batch window expires\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
ddfbf9f67a59-1
+ **Increase Kinesis stream processing throughput by adding shards\.** A Kinesis stream is composed of one or more shards\. Lambda will poll each shard with at most one concurrent invocation\. For example, if your stream has 100 active shards, there will be at most 100 Lambda function invocations running concurrently\. Increasing the number of shards will directly increase the number of maximum concurrent Lambda function invocations and can increase your Kinesis stream processing throughput\. If you are increasing the number of shards in a Kinesis stream, make sure you have picked a good partition key \(see [Partition Keys](https://docs.aws.amazon.com/streams/latest/dev/key-concepts.html#partition-key)\) for your data, so that related records end up on the same shards and your data is well distributed\. + **Use [Amazon CloudWatch](https://docs.aws.amazon.com/streams/latest/dev/monitoring-with-cloudwatch.html)** on IteratorAge to determine if your Kinesis stream is being processed\. For example, configure a CloudWatch alarm with a maximum setting to 30000 \(30 seconds\)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/best-practices.md
395f51ac1693-0
Amazon Kinesis Data Firehose captures, transforms, and loads streaming data into downstream services such as Kinesis Data Analytics or Amazon S3\. You can write Lambda functions to request additional, customized processing of the data before it is sent downstream\. **Example Amazon Kinesis Data Firehose message event** ``` { "invocationId": "invoked123", "deliveryStreamArn": "aws:lambda:events", "region": "us-west-2", "records": [ { "data": "SGVsbG8gV29ybGQ=", "recordId": "record1", "approximateArrivalTimestamp": 1510772160000, "kinesisRecordMetadata": { "shardId": "shardId-000000000000", "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c317a", "approximateArrivalTimestamp": "2012-04-23T18:25:43.511Z", "sequenceNumber": "49546986683135544286507457936321625675700192471156785154", "subsequenceNumber": "" } },
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-kinesisfirehose.md
395f51ac1693-1
"subsequenceNumber": "" } }, { "data": "SGVsbG8gV29ybGQ=", "recordId": "record2", "approximateArrivalTimestamp": 151077216000, "kinesisRecordMetadata": { "shardId": "shardId-000000000001", "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c318a", "approximateArrivalTimestamp": "2012-04-23T19:25:43.511Z", "sequenceNumber": "49546986683135544286507457936321625675700192471156785155", "subsequenceNumber": "" } } ] } ``` For more information, see [Amazon Kinesis Data Firehose data transformation ](https://docs.aws.amazon.com/firehose/latest/dev/data-transformation.html) in the Kinesis Data Firehose Developer Guide\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-kinesisfirehose.md
82ce62a7a957-0
A destination for events that were processed successfully\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_OnSuccess.md
4f6763f132db-0
**Destination** <a name="SSS-Type-OnSuccess-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_OnSuccess.md
e1889bfd8c9c-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/OnSuccess) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/OnSuccess) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/OnSuccess) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/OnSuccess)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_OnSuccess.md
4c0b1b78b1a4-0
You can use the Lambda console to create an application with an integrated continuous delivery pipeline\. With continuous delivery, every change that you push to your source control repository triggers a pipeline that builds and deploys your application automatically\. The Lambda console provides starter projects for common application types with Node\.js sample code and templates that create supporting resources\. In this tutorial, you create the following resources\. + **Application** – A Node\.js Lambda function, build specification, and AWS Serverless Application Model \(AWS SAM\) template\. + **Pipeline** – An AWS CodePipeline pipeline that connects the other resources to enable continuous delivery\. + **Repository** – A Git repository in AWS CodeCommit\. When you push a change, the pipeline copies the source code into an Amazon S3 bucket and passes it to the build project\. + **Trigger** – An Amazon CloudWatch Events rule that watches the master branch of the repository and triggers the pipeline\. + **Build project** – An AWS CodeBuild build that gets the source code from the pipeline and packages the application\. The source includes a build specification with commands that install dependencies and prepare the application template for deployment\. + **Deployment configuration** – The pipeline's deployment stage defines a set of actions that take the processed AWS SAM template from the build output, and deploy the new version with AWS CloudFormation\. + **Bucket** – An Amazon Simple Storage Service \(Amazon S3\) bucket for deployment artifact storage\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
4c0b1b78b1a4-1
+ **Bucket** – An Amazon Simple Storage Service \(Amazon S3\) bucket for deployment artifact storage\. + **Roles** – The pipeline's source, build, and deploy stages have IAM roles that allow them to manage AWS resources\. The application's function has an [execution role](lambda-intro-execution-role.md) that allows it to upload logs and can be extended to access other services\. Your application and pipeline resources are defined in AWS CloudFormation templates that you can customize and extend\. Your application repository includes a template that you can modify to add Amazon DynamoDB tables, an Amazon API Gateway API, and other application resources\. The continuous delivery pipeline is defined in a separate template outside of source control and has its own stack\. The pipeline maps a single branch in a repository to a single application stack\. You can create additional pipelines to add environments for other branches in the same repository\. You can also add stages to your pipeline for testing, staging, and manual approvals\. For more information about AWS CodePipeline, see [What is AWS CodePipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html)\. **Topics** + [Prerequisites](#applications-tutorial-prepare) + [Create an application](#applications-tutorial-wizard) + [Invoke the function](#applications-tutorial-invoke) + [Add an AWS resource](#applications-tutorial-update)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
4c0b1b78b1a4-2
+ [Add an AWS resource](#applications-tutorial-update) + [Update the permissions boundary](#applications-tutorial-permissions) + [Update the function code](#applications-tutorial-code) + [Next steps](#applications-tutorial-nextsteps) + [Troubleshooting](#applications-tutorial-troubleshooting) + [Clean up](#applications-tutorial-cleanup)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
66d5e5fdbefc-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\. This tutorial uses CodeCommit for source control\. To set up your local machine to access and update application code, see [Setting up](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up.html) in the *AWS CodeCommit User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
e01ba6ba5ea7-0
Create an application in the Lambda console\. In Lambda, an application is an AWS CloudFormation stack with a Lambda function and any number of supporting resources\. In this tutorial, you create an application that has a function and its execution role\. **To create an application** 1. Open the Lambda console [Applications page](https://console.aws.amazon.com/lambda/home#/applications)\. 1. Choose **Create application**\. 1. Choose **Author from scratch**\. 1. Configure application settings\. + **Application name** – **my\-app**\. + **Application description** – **my application**\. + **Runtime** – **Node\.js 10\.x**\. + **Source control service** – **CodeCommit**\. + **Repository name** – **my\-app\-repo**\. + **Permissions** – **Create roles and permissions boundary**\. 1. Choose **Create**\. Lambda creates the pipeline and related resources and commits the sample application code to the Git repository\. As resources are created, they appear on the overview page\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/application-create-resources.png)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
e01ba6ba5ea7-1
The **Infrastructure** stack contains the repository, build project, and other resources that combine to form a continuous delivery pipeline\. When this stack finishes deploying, it in turn deploys the application stack that contains the function and execution role\. These are the application resources that appear under **Resources**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
2e9d0d76d7e6-0
When the deployment process completes, invoke the function from the Lambda console\. **To invoke the application's function** 1. Open the Lambda console [Applications page](https://console.aws.amazon.com/lambda/home#/applications)\. 1. Choose **my\-app**\. 1. Under **Resources**, choose **helloFromLambdaFunction**\. 1. Choose **Test**\. 1. Configure a test event\. + **Event name** – **event** + **Body** – **\{\}** 1. Choose **Create**\. 1. Choose **Test**\. The Lambda console executes your function and displays the result\. Expand the **Details** section under the result to see the output and execution details\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/application-create-result.png)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
a5f9928c975c-0
In the previous step, Lambda console created a Git repository that contains function code, a template, and a build specification\. You can add resources to your application by modifying the template and pushing changes to the repository\. To get a copy of the application on your local machine, clone the repository\. **To clone the project repository** 1. Open the Lambda console [Applications page](https://console.aws.amazon.com/lambda/home#/applications)\. 1. Choose **my\-app**\. 1. Choose **Code**\. 1. Under **Repository details**, copy the HTTP or SSH repository URI, depending on the authentication mode that you configured during [setup](#applications-tutorial-prepare)\. 1. To clone the repository, use the `git clone` command\. ``` ~$ git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/my-app-repo ``` To add a DynamoDB table to the application, define an `AWS::Serverless::SimpleTable` resource in the template\. **To add a DynamoDB table** 1. Open `template.yml` in a text editor\. 1. Add a table resource, an environment variable that passes the table name to the function, and a permissions policy that allows the function to manage it\. **Example template\.yml \- resources** ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
a5f9928c975c-1
**Example template\.yml \- resources** ``` ... Resources: ddbTable: Type: AWS::Serverless::SimpleTable Properties: PrimaryKey: Name: id Type: String ProvisionedThroughput: ReadCapacityUnits: 1 WriteCapacityUnits: 1 helloFromLambdaFunction: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: CodeUri: ./ Handler: src/handlers/hello-from-lambda.helloFromLambdaHandler Runtime: nodejs10.x MemorySize: 128 Timeout: 60 Description: A Lambda function that returns a static string. Environment: Variables: DDB_TABLE: !Ref ddbTable Policies: - DynamoDBCrudPolicy: TableName: !Ref ddbTable - AWSLambdaBasicExecutionRole ``` 1. Commit and push the change\. ``` ~/my-app-repo$ git commit -am "Add DynamoDB table"
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
a5f9928c975c-2
``` ~/my-app-repo$ git commit -am "Add DynamoDB table" ~/my-app-repo$ git push ``` When you push a change, it triggers the application's pipeline\. Use the **Deployments** tab of the application screen to track the change as it flows through the pipeline\. When the deployment is complete, proceed to the next step\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/application-create-deployment.png)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
6210e8bcd695-0
The sample application applies a *permissions boundary* to its function's execution role\. The permissions boundary limits the permissions that you can add to the function's role\. Without the boundary, users with write access to the project repository could modify the project template to give the function permission to access resources and services outside of the scope of the sample application\. In order for the function to use the DynamoDB permission that you added to its execution role in the previous step, you must extend the permissions boundary to allow the additional permissions\. The Lambda console detects resources that aren't in the permissions boundary and provides an updated policy that you can use to update it\. **To update the application's permissions boundary** 1. Open the Lambda console [Applications page](https://console.aws.amazon.com/lambda/home#/applications)\. 1. Choose your application\. 1. Under **Resources**, choose **Edit permissions boundary**\. 1. Follow the instructions shown to update the boundary to allow access to the new table\. For more information about permissions boundaries, see [Using permissions boundaries for AWS Lambda applications](permissions-boundary.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
5b9f07690031-0
Next, update the function code to use the table\. The following code uses the DynamoDB table to track the number of invocations processed by each instance of the function\. It uses the log stream ID as a unique identifier for the function instance\. **To update the function code** 1. Add a new handler named `index.js` to the `src/handlers` folder with the following content\. **Example src/handlers/index\.js** ``` const dynamodb = require('aws-sdk/clients/dynamodb'); const docClient = new dynamodb.DocumentClient(); exports.handler = async (event, context) => { const message = 'Hello from Lambda!'; const tableName = process.env.DDB_TABLE; const logStreamName = context.logStreamName; var params = { TableName : tableName, Key: { id : logStreamName }, UpdateExpression: 'set invocations = if_not_exists(invocations, :start) + :inc', ExpressionAttributeValues: { ':start': 0, ':inc': 1 }, ReturnValues: 'ALL_NEW' }; await docClient.update(params).promise(); const response = {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
5b9f07690031-1
}; await docClient.update(params).promise(); const response = { body: JSON.stringify(message) }; console.log(`body: ${response.body}`); return response; } ``` 1. Open the application template and change the handler value to `src/handlers/index.handler`\. **Example template\.yml** ``` ... helloFromLambdaFunction: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: CodeUri: ./ Handler: src/handlers/index.handler Runtime: nodejs10.x ``` 1. Commit and push the change\. ``` ~/my-app-repo$ git add . && git commit -m "Use DynamoDB table" ~/my-app-repo$ git push ``` After the code change is deployed, invoke the function a few times to update the DynamoDB table\. **To view the DynamoDB table**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
5b9f07690031-2
After the code change is deployed, invoke the function a few times to update the DynamoDB table\. **To view the DynamoDB table** 1. Open the [Tables page of the DynamoDB console](https://console.aws.amazon.com/dynamodb/home#tables:)\. 1. Choose the table that starts with **my\-app**\. 1. Choose **Items**\. 1. Choose **Start search**\. ![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/application-create-ddbtable.png) Lambda creates additional instances of your function to handle multiple concurrent invocations\. Each log stream in the CloudWatch Logs log group corresponds to a function instance\. A new function instance is also created when you change your function's code or configuration\. For more information on scaling, see [AWS Lambda function scaling](invocation-scaling.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
3a979b60c5db-0
The AWS CloudFormation template that defines your application resources uses the AWS Serverless Application Model transform to simplify the syntax for resource definitions, and automate uploading the deployment package and other artifacts\. AWS SAM also provides a command line interface \(the AWS SAM CLI\), which has the same packaging and deployment functionality as the AWS CLI, with additional features specific to Lambda applications\. Use the AWS SAM CLI to test your application locally in a Docker container that emulates the Lambda execution environment\. + [Installing the AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) + [Testing and debugging serverless applications](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-test-and-debug.html) AWS Cloud9 provides an online development environment that includes Node\.js, the AWS SAM CLI, and Docker\. With AWS Cloud9, you can start developing quickly and access your development environment from any computer\. For instructions, see [Getting started](https://docs.aws.amazon.com/cloud9/latest/user-guide/get-started.html) in the *AWS Cloud9 User Guide*\. For local development, AWS toolkits for integrated development environments \(IDEs\) let you test and debug functions before pushing them to your repository\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
3a979b60c5db-1
For local development, AWS toolkits for integrated development environments \(IDEs\) let you test and debug functions before pushing them to your repository\. + [AWS Toolkit for JetBrains](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/) – Plugin for PyCharm \(Python\) and IntelliJ \(Java\) IDEs\. + [AWS Toolkit for Eclipse](https://docs.aws.amazon.com/AWSToolkitEclipse/latest/GettingStartedGuide/) – Plugin for Eclipse IDE \(multiple languages\)\. + [AWS Toolkit for Visual Studio Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/) – Plugin for Visual Studio Code IDE \(multiple languages\)\. + [AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/) – Plugin for Visual Studio IDE \(multiple languages\)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
c0570b5d0401-0
As you develop your application, you will likely encounter the following types of errors\. + **Build errors** – Issues that occur during the build phase, including compilation, test, and packaging errors\. + **Deployment errors** – Issues that occur when AWS CloudFormation isn't able to update the application stack\. These include permissions errors, account quotas, service issues, or template errors\. + **Invocation errors** – Errors that are returned by a function's code or runtime\. For build and deployment errors, you can identify the cause of an error in the Lambda console\. **To troubleshoot application errors** 1. Open the Lambda console [Applications page](https://console.aws.amazon.com/lambda/home#/applications)\. 1. Choose an application\. 1. Choose **Deployments**\. 1. To view the application's pipeline, choose **Deployment pipeline**\. 1. Identify the action that encountered an error\. 1. To view the error in context, choose **Details**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
c0570b5d0401-1
1. Identify the action that encountered an error\. 1. To view the error in context, choose **Details**\. For deployment errors that occur during the **ExecuteChangeSet** action, the pipeline links to a list of stack events in the AWS CloudFormation console\. Search for an event with the status **UPDATE\_FAILED**\. Because AWS CloudFormation rolls back after an error, the relevant event is under several other events in the list\. If AWS CloudFormation could not create a change set, the error appears under **Change sets** instead of under **Events**\. A common cause of deployment and invocation errors is a lack of permissions in one or more roles\. The pipeline has a role for deployments \(`CloudFormationRole`\) that's equivalent to the [user permissions](access-control-identity-based.md) that you would use to update an AWS CloudFormation stack directly\. If you add resources to your application or enable Lambda features that require user permissions, the deployment role is used\. You can find a link to the deployment role under **Infrastructure** in the application overview\. If your function accesses other AWS services or resources, or if you enable features that require the function to have additional permissions, the function's [execution role](lambda-intro-execution-role.md) is used\. All execution roles that are created in your application template are also subject to the application's permissions boundary\. This boundary requires you to explicitly grant access to additional services and resources in IAM after adding permissions to the execution role in the template\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
c0570b5d0401-2
For example, to [connect a function to a virtual private cloud](configuration-vpc.md) \(VPC\), you need user permissions to describe VPC resources\. The execution role needs permission to manage network interfaces\. This requires the following steps\. 1. Add the required user permissions to the deployment role in IAM\. 1. Add the execution role permissions to the permissions boundary in IAM\. 1. Add the execution role permissions to the execution role in the application template\. 1. Commit and push to deploy the updated execution role\. After you address permissions errors, choose **Release change** in the pipeline overview to rerun the build and deployment\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
2fc83f09a64e-0
You can continue to modify and use the sample to develop your own application\. If you are done using the sample, delete the application to avoid paying for the pipeline, repository, and storage\. **To delete the application** 1. Open the [AWS CloudFormation console](https://console.aws.amazon.com/cloudformation)\. 1. Delete the application stack – **my\-app**\. 1. Open the [Amazon S3 console](https://console.aws.amazon.com/s3)\. 1. Delete the artifact bucket – **aws\-*us\-east\-2*\-*123456789012*\-my\-app\-pipe**\. 1. Return to the AWS CloudFormation console and delete the infrastructure stack – **serverlessrepo\-my\-app\-toolchain**\. Function logs are not associated with the application or infrastructure stack in AWS CloudFormation\. Delete the log group separately in the CloudWatch Logs console\. **To delete the log group** 1. Open the [Log groups page](https://console.aws.amazon.com/cloudwatch/home#logs:) of the Amazon CloudWatch console\. 1. Choose the function's log group \(`/aws/lambda/my-app-helloFromLambdaFunction-YV1VXMPLK7QK`\)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
2fc83f09a64e-1
1. Choose **Actions**, and then choose **Delete log group**\. 1. Choose **Yes, Delete**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-tutorial.md
4e78d44e1b08-0
Creates a Lambda function\. To create a function, you need a [deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html) and an [execution role](https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role)\. The deployment package contains your function code\. The execution role grants the function permission to use AWS services, such as Amazon CloudWatch Logs for log streaming and AWS X\-Ray for request tracing\. When you create a function, Lambda provisions an instance of the function and its supporting resources\. If your function connects to a VPC, this process can take a minute or so\. During this time, you can't invoke or modify the function\. The `State`, `StateReason`, and `StateReasonCode` fields in the response from [GetFunctionConfiguration](API_GetFunctionConfiguration.md) indicate when the function is ready to invoke\. For more information, see [Function States](https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html)\. A function has an unpublished version, and can have published versions and aliases\. The unpublished version changes when you update your function's code and configuration\. A published version is a snapshot of your function code and configuration that can't be changed\. An alias is a named resource that maps to a version, and can be changed to map to a different version\. Use the `Publish` parameter to create version `1` of your function from its initial configuration\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
4e78d44e1b08-1
The other parameters let you configure version\-specific and function\-level settings\. You can modify version\-specific settings later with [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md)\. Function\-level settings apply to both the unpublished and published versions of the function, and include tags \([TagResource](API_TagResource.md)\) and per\-function concurrency limits \([PutFunctionConcurrency](API_PutFunctionConcurrency.md)\)\. If another account or an AWS service invokes your function, use [AddPermission](API_AddPermission.md) to grant permission by creating a resource\-based IAM policy\. You can grant permissions at the function level, on a version, or on an alias\. To invoke your function directly, use [Invoke](API_Invoke.md)\. To invoke your function in response to events in other AWS services, create an event source mapping \([CreateEventSourceMapping](API_CreateEventSourceMapping.md)\), or configure a function trigger in the other service\. For more information, see [Invoking Functions](https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
38f32f8c2648-0
``` POST /2015-03-31/functions HTTP/1.1 Content-type: application/json { "Code": { "S3Bucket": "string", "S3Key": "string", "S3ObjectVersion": "string", "ZipFile": blob }, "DeadLetterConfig": { "TargetArn": "string" }, "Description": "string", "Environment": { "Variables": { "string" : "string" } }, "FileSystemConfigs": [ { "Arn": "string", "LocalMountPath": "string" } ], "FunctionName": "string", "Handler": "string", "KMSKeyArn": "string", "Layers": [ "string" ], "MemorySize": number, "Publish": boolean, "Role": "string", "Runtime": "string", "Tags": { "string" : "string" }, "Timeout": number,
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
38f32f8c2648-1
"Tags": { "string" : "string" }, "Timeout": number, "TracingConfig": { "Mode": "string" }, "VpcConfig": { "SecurityGroupIds": [ "string" ], "SubnetIds": [ "string" ] } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
2f6e8aa2ddc6-0
The request does not use any URI parameters\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-0
The request accepts the following data in JSON format\. ** [Code](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Code"></a> The code for the function\. Type: [FunctionCode](API_FunctionCode.md) object Required: Yes ** [DeadLetterConfig](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-DeadLetterConfig"></a> A dead letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing\. For more information, see [Dead Letter Queues](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#dlq)\. Type: [DeadLetterConfig](API_DeadLetterConfig.md) object Required: No ** [Description](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Description"></a> A description of the function\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\. Required: No ** [Environment](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Environment"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-1
Environment variables that are accessible from function code during execution\. Type: [Environment](API_Environment.md) object Required: No ** [FileSystemConfigs](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-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 ** [FunctionName](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-FunctionName"></a> The name of the Lambda function\. **Name formats** + **Function name** \- `my-function`\. + **Function ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:my-function`\. + **Partial ARN** \- `123456789012:function:my-function`\. The length constraint applies only to the full ARN\. If you specify only the function name, it is limited to 64 characters in length\. Type: String 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_CreateFunction.md
ded1e280603d-2
Type: String 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 ** [Handler](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Handler"></a> The name of the method within your code that Lambda calls to execute your function\. The format includes the file name\. It can also include namespaces and other qualifiers, depending on the runtime\. For more information, see [Programming Model](https://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html)\. Type: String Length Constraints: Maximum length of 128\. Pattern: `[^\s]+` Required: Yes ** [KMSKeyArn](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-KMSKeyArn"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-3
The ARN of the AWS Key Management Service \(AWS KMS\) key that's used to encrypt your function's environment variables\. If it's not provided, AWS Lambda uses a default service key\. Type: String Pattern: `(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()` Required: No ** [Layers](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Layers"></a> A list of [function layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) to add to the function's execution environment\. Specify each layer by its ARN, including the version\. Type: Array of strings Length Constraints: Minimum length of 1\. Maximum length of 140\. Pattern: `arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+:[0-9]+` Required: No ** [MemorySize](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-MemorySize"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-4
The amount of memory that your function has access to\. Increasing the function's memory also increases its CPU allocation\. The default value is 128 MB\. The value must be a multiple of 64 MB\. Type: Integer Valid Range: Minimum value of 128\. Maximum value of 3008\. Required: No ** [Publish](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Publish"></a> Set to true to publish the first version of the function during creation\. Type: Boolean Required: No ** [Role](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Role"></a> The Amazon Resource Name \(ARN\) of the function's execution role\. Type: String Pattern: `arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+` Required: Yes ** [Runtime](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Runtime"></a> The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-5
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: Yes ** [Tags](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Tags"></a> A list of [tags](https://docs.aws.amazon.com/lambda/latest/dg/tagging.html) to apply to the function\. Type: String to string map Required: No ** [Timeout](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-Timeout"></a> 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\. Type: Integer Valid Range: Minimum value of 1\. Required: No ** [TracingConfig](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-TracingConfig"></a> Set `Mode` to `Active` to sample and trace a subset of incoming requests with AWS X\-Ray\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
ded1e280603d-6
Set `Mode` to `Active` to sample and trace a subset of incoming requests with AWS X\-Ray\. Type: [TracingConfig](API_TracingConfig.md) object Required: No ** [VpcConfig](#API_CreateFunction_RequestSyntax) ** <a name="SSS-CreateFunction-request-VpcConfig"></a> For network connectivity to AWS resources in a VPC, specify a list of security groups and subnets in the VPC\. When you connect a function to a VPC, it can only access resources and the internet through that VPC\. For more information, see [VPC Settings](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html)\. Type: [VpcConfig](API_VpcConfig.md) object Required: No
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
f600dac90408-0
``` HTTP/1.1 201 Content-type: application/json { "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", "LastUpdateStatus": "string", "LastUpdateStatusReason": "string", "LastUpdateStatusReasonCode": "string", "Layers": [ { "Arn": "string", "CodeSize": number
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
f600dac90408-1
"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" } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-0
If the action is successful, the service sends back an HTTP 201 response\. The following data is returned in JSON format by the service\. ** [CodeSha256](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-CodeSha256"></a> The SHA256 hash of the function's deployment package\. Type: String ** [CodeSize](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-CodeSize"></a> The size of the function's deployment package, in bytes\. Type: Long ** [DeadLetterConfig](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-DeadLetterConfig"></a> The function's dead letter queue\. Type: [DeadLetterConfig](API_DeadLetterConfig.md) object ** [Description](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Description"></a> The function's description\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-1
The function's description\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\. ** [Environment](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Environment"></a> The function's environment variables\. Type: [EnvironmentResponse](API_EnvironmentResponse.md) object ** [FileSystemConfigs](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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\. ** [FunctionArn](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-FunctionArn"></a> The function's Amazon Resource Name \(ARN\)\. Type: String
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-2
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-_]+))?` ** [FunctionName](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-FunctionName"></a> 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-_]+))?` ** [Handler](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Handler"></a> The function that Lambda calls to begin executing your function\. Type: String
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-3
The function that Lambda calls to begin executing your function\. Type: String Length Constraints: Maximum length of 128\. Pattern: `[^\s]+` ** [KMSKeyArn](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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-.]+:.*)|()` ** [LastModified](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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 ** [LastUpdateStatus](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-LastUpdateStatus"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-4
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` ** [LastUpdateStatusReason](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-LastUpdateStatusReason"></a> The reason for the last update that was performed on the function\. Type: String ** [LastUpdateStatusReasonCode](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-LastUpdateStatusReasonCode"></a> The reason code for the last update that was performed on the function\. Type: String Valid Values:` EniLimitExceeded | InsufficientRolePermissions | InvalidConfiguration | InternalError | SubnetOutOfIPAddresses | InvalidSubnet | InvalidSecurityGroup` ** [Layers](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-5
Type: Array of [Layer](API_Layer.md) objects ** [MasterArn](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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-_]+))?` ** [MemorySize](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-MemorySize"></a> The memory that's allocated to the function\. Type: Integer Valid Range: Minimum value of 128\. Maximum value of 3008\. ** [RevisionId](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-RevisionId"></a> The latest updated revision of the function or alias\. Type: String ** [Role](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Role"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-6
The function's execution role\. Type: String Pattern: `arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+` ** [Runtime](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Runtime"></a> 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` ** [State](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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` ** [StateReason](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-StateReason"></a> The reason for the function's current state\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-7
The reason for the function's current state\. Type: String ** [StateReasonCode](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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 Valid Values:` Idle | Creating | Restoring | EniLimitExceeded | InsufficientRolePermissions | InvalidConfiguration | InternalError | SubnetOutOfIPAddresses | InvalidSubnet | InvalidSecurityGroup` ** [Timeout](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-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\. ** [TracingConfig](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-TracingConfig"></a> The function's AWS X\-Ray tracing configuration\. Type: [TracingConfigResponse](API_TracingConfigResponse.md) object
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
b25a707f383e-8
Type: [TracingConfigResponse](API_TracingConfigResponse.md) object ** [Version](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-Version"></a> The version of the Lambda function\. Type: String Length Constraints: Minimum length of 1\. Maximum length of 1024\. Pattern: `(\$LATEST|[0-9]+)` ** [VpcConfig](#API_CreateFunction_ResponseSyntax) ** <a name="SSS-CreateFunction-response-VpcConfig"></a> The function's networking configuration\. Type: [VpcConfigResponse](API_VpcConfigResponse.md) object
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
cf97c666afc3-0
**CodeStorageExceededException** You have exceeded your maximum total code size per account\. [Learn more](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) HTTP Status Code: 400 **InvalidParameterValueException** One of the parameters in the request is invalid\. HTTP Status Code: 400 **ResourceConflictException** The resource already exists, or another operation is in progress\. HTTP Status Code: 409 **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_CreateFunction.md
71e237453de0-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/CreateFunction) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/CreateFunction) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/CreateFunction) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/CreateFunction) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/CreateFunction) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/CreateFunction) + [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/CreateFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
71e237453de0-1
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/CreateFunction) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/CreateFunction)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_CreateFunction.md
57f179d2977a-0
You can use identity\-based policies in AWS Identity and Access Management \(IAM\) to grant users in your account access to Lambda\. Identity\-based policies can apply to users directly, or to groups and roles that are associated with a user\. You can also grant users in another account permission to assume a role in your account and access your Lambda resources\. Lambda provides managed policies that grant access to Lambda API actions and, in some cases, access to other services used to develop and manage Lambda resources\. Lambda updates the managed policies as needed, to ensure that your users have access to new features when they're released\. + **AWSLambdaFullAccess** – Grants full access to AWS Lambda actions and other services used to develop and maintain Lambda resources\. + **AWSLambdaReadOnlyAccess** – Grants read\-only access to AWS Lambda resources\. + **AWSLambdaRole** – Grants permissions to invoke Lambda functions\. Managed policies grant permission to API actions without restricting the functions or layers that a user can modify\. For finer\-grained control, you can create your own policies that limit the scope of a user's permissions\. **Topics** + [Function development](#permissions-user-function) + [Layer development and use](#permissions-user-layer) + [Cross\-account roles](#permissions-user-xaccount) + [Condition keys for VPC settings](#permissions-condition-keys)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/access-control-identity-based.md
c628232e7b73-0
The following shows an example of a permissions policy with limited scope\. It allows a user to create and manage Lambda functions named with a designated prefix \(`intern-`\), and configured with a designated execution role\. **Example Function development policy** ``` { "Version": "2012-10-17", "Statement": [ { "Sid": "ReadOnlyPermissions", "Effect": "Allow", "Action": [ "lambda:GetAccountSettings", "lambda:ListFunctions", "lambda:ListTags", "lambda:GetEventSourceMapping", "lambda:ListEventSourceMappings", "iam:ListRoles" ], "Resource": "*" }, { "Sid": "DevelopFunctions", "Effect": "Allow", "NotAction": [ "lambda:AddPermission", "lambda:PutFunctionConcurrency" ], "Resource": "arn:aws:lambda:*:*:function:intern-*" }, { "Sid": "DevelopEventSourceMappings", "Effect": "Allow",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/access-control-identity-based.md