id
stringlengths 14
16
| text
stringlengths 1
2.43k
| source
stringlengths 99
229
|
|---|---|---|
80d45c809765-0
|
**TargetArn** <a name="SSS-Type-DeadLetterConfig-TargetArn"></a>
The Amazon Resource Name \(ARN\) of an Amazon SQS queue or Amazon SNS topic\.
Type: String
Pattern: `(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()`
Required: No
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DeadLetterConfig.md
|
a85dc5b92792-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/DeadLetterConfig)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/DeadLetterConfig)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/DeadLetterConfig)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/DeadLetterConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_DeadLetterConfig.md
|
8f43d584498b-0
|
You can run Ruby code in AWS Lambda\. Lambda provides [runtimes](lambda-runtimes.md) for Ruby that execute your code to process events\. Your code runs in an environment that includes the AWS SDK for Ruby, with credentials from an AWS Identity and Access Management \(IAM\) role that you manage\.
Lambda supports the following Ruby runtimes\.
**Ruby runtimes**
| Name | Identifier | AWS SDK for Ruby | Operating system |
| --- | --- | --- | --- |
| Ruby 2\.7 | `ruby2.7` | 3\.0\.1 | Amazon Linux 2 |
| Ruby 2\.5 | `ruby2.5` | 3\.0\.1 | 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**\.
+ **Permissions** β **AWSLambdaBasicExecutionRole**\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-ruby.md
|
8f43d584498b-1
|
+ **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 Ruby 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** β **Ruby 2\.7**\.
+ **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**\.
1. To execute the function, choose **Test**\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-ruby.md
|
8f43d584498b-2
|
1. Choose **Create**\.
1. To execute the function, choose **Test**\.
The console creates a Lambda function with a single source file named `lambda_function.rb`\. You can edit this file and add more files in the built\-in [code editor](code-editor.md)\. To save your changes, choose **Save**\. Then, to run your code, choose **Test**\.
**Note**
The Lambda console uses AWS Cloud9 to provide an integrated development environment in the browser\. You can also use AWS Cloud9 to develop Lambda functions in your own environment\. For more information, see [Working with AWS Lambda Functions](https://docs.aws.amazon.com/cloud9/latest/user-guide/lambda-functions.html) in the AWS Cloud9 user guide\.
The `lambda_function.rb` file exports a function named `lambda_handler` that takes an event object and a context object\. This is the [handler function](ruby-handler.md) that Lambda calls when the function is invoked\. The Ruby function runtime gets invocation events from Lambda and passes them to the handler\. In the function configuration, the handler value is `lambda_function.lambda_handler`\.
Each time you save your function code, the Lambda console creates 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](ruby-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-ruby.md
|
8f43d584498b-3
|
**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\-ruby](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-ruby) β A Ruby function that shows the use of logging, environment variables, AWS X\-Ray tracing, layers, unit tests and the AWS SDK\.
The function runtime passes a context object to the handler, in addition to the invocation event\. The [context object](ruby-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](ruby-logging.md) during invocation\. If your function [returns an error](ruby-exceptions.md), Lambda formats the error and returns it to the invoker\.
**Topics**
+ [AWS Lambda function handler in Ruby](ruby-handler.md)
+ [AWS Lambda deployment package in Ruby](ruby-package.md)
+ [AWS Lambda context object in Ruby](ruby-context.md)
+ [AWS Lambda function logging in Ruby](ruby-logging.md)
+ [AWS Lambda function errors in Ruby](ruby-exceptions.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-ruby.md
|
8f43d584498b-4
|
+ [AWS Lambda function logging in Ruby](ruby-logging.md)
+ [AWS Lambda function errors in Ruby](ruby-exceptions.md)
+ [Instrumenting Ruby code in AWS Lambda](ruby-tracing.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-ruby.md
|
dddd2b643450-0
|
AWS Lambda automatically monitors Lambda functions on your behalf and reports metrics through Amazon CloudWatch\. To help you monitor your code as it executes, Lambda automatically tracks the number of requests, the execution duration per request, and the number of requests that result in an error\. It also publishes the associated CloudWatch metrics\. You can leverage these metrics to set CloudWatch custom alarms\.
The Lambda console provides a built\-in [monitoring dashboard](monitoring-functions-access-metrics.md) for each of your functions and applications\.
**To monitor a function**
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
1. Choose a function\.
1. Choose **Monitoring**\.
**Pricing**
CloudWatch has a perpetual free tier\. Beyond the free tier threshold, CloudWatch charges for metrics, dashboards, alarms, logs, and insights\. For details, see [CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/)\.
Each time your function is invoked, Lambda records [metrics](monitoring-metrics.md) for the request, the function's response, and the overall state of the function\. You can use metrics to set alarms the are triggered when function performance degrades, or when you are close to hitting concurrency limits in the current Region\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-monitoring.md
|
dddd2b643450-1
|
To debug and validate that your code is working as expected, you can output logs with the standard logging functionality for your programming language\. The Lambda runtime uploads your function's log output to CloudWatch Logs\. You can [view logs](monitoring-cloudwatchlogs.md) in the CloudWatch Logs console, in the Lambda console, or from the command line\.
In addition to monitoring logs and metrics in CloudWatch, you can use AWS X\-Ray to trace and debug requests served by your application\. For details, see [Using AWS Lambda with AWS X\-Ray](services-xray.md)\.
**Topics**
+ [Monitoring functions in the AWS Lambda console](monitoring-functions-access-metrics.md)
+ [Working with AWS Lambda function metrics](monitoring-metrics.md)
+ [Accessing Amazon CloudWatch logs for AWS Lambda](monitoring-cloudwatchlogs.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-monitoring.md
|
89e54ef7b82f-0
|
If your Lambda function has a terminating error, AWS Lambda recognizes the failure, serializes the error information into JSON, and returns it\.
Consider the following PowerShell script example statement:
```
throw 'The Account is not found'
```
When you invoke this Lambda function, it throws a terminating error, and AWS Lambda returns the following error message:
```
{
"errorMessage": "The Account is not found",
"errorType": "RuntimeException"
}
```
Note the `errorType` is `RuntimeException`, which is the default exception thrown by PowerShell\. You can use custom error types by throwing the error like this:
```
throw @{'Exception'='AccountNotFound';'Message'='The Account is not found'}
```
The error message is serialized with `errorType` set to `AccountNotFound`:
```
{
"errorMessage": "The Account is not found",
"errorType": "AccountNotFound"
}
```
If you don't need an error message, you can throw a string in the format of an error code\. The error code format requires that the string starts with a character and only contain letters and digits afterwards, with no spaces or symbols\.
For example, if your Lambda function contains the following:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/powershell-exceptions.md
|
89e54ef7b82f-1
|
For example, if your Lambda function contains the following:
```
throw 'AccountNotFound'
```
The error is serialized like this:
```
{
"errorMessage": "AccountNotFound",
"errorType": "AccountNotFound"
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/powershell-exceptions.md
|
52e7e1fdb640-0
|
[AWS Lambda runtimes](lambda-runtimes.md) are built around a combination of operating system, programming language, and software libraries that are subject to maintenance and security updates\. When a component of a runtime is no longer supported for security updates, Lambda deprecates the runtime\.
Deprecation occurs in two phases\. During the first phase, you can no longer create functions that use the deprecated runtime\. For at least 30 days, you can continue to update existing functions that use the deprecated runtime\. After this period, both function creation and updates are disabled permanently\. However, the function continues to be available to process invocation events\.
**Note**
Python 2\.7 reached end\-of\-life on January 1st, 2020\. However, the Python 2\.7 runtime is still supported and is not scheduled to be deprecated at this time\. For details, see [Continued support for Python 2\.7 on AWS Lambda](https://aws.amazon.com/blogs/compute/continued-support-for-python-2-7-on-aws-lambda/)\.
The following runtimes have been deprecated:
**Deprecated runtimes**
| Name | Identifier | Operating system | Deprecation completed date |
| --- | --- | --- | --- |
| \.NET Core 1\.0 | `dotnetcore1.0` | Amazon Linux | July 30, 2019 |
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtime-support-policy.md
|
52e7e1fdb640-1
|
| \.NET Core 1\.0 | `dotnetcore1.0` | Amazon Linux | July 30, 2019 |
| \.NET Core 2\.0 | `dotnetcore2.0` | Amazon Linux | May 30, 2019 |
| Node\.js 0\.10 | `nodejs` | Amazon Linux | October 31, 2016 |
| Node\.js 4\.3 | `nodejs4.3` | Amazon Linux | March 6, 2020 |
| Node\.js 4\.3 edge | `nodejs4.3-edge` | Amazon Linux | April 30, 2019 |
| Node\.js 6\.10 | `nodejs6.10` | Amazon Linux | August 12, 2019 |
| Node\.js 8\.10 | `nodejs8.10` | Amazon Linux | March 6, 2020 |
In most cases, the end\-of\-life date of a language version or operating system is known well in advance\. If you have functions running on a runtime that will be deprecated in the next 60 days, Lambda notifies you by email that you should prepare by migrating your function to a supported runtime\. In some cases, such as security issues that require a backwards\-incompatible update, or software that doesn't support a long\-term support \(LTS\) schedule, advance notice might not be possible\.
**Language and framework support policies**
+ **Node\.js** β [github\.com](https://github.com/nodejs/Release#release-schedule)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtime-support-policy.md
|
52e7e1fdb640-2
|
+ **Python** β [devguide\.python\.org](https://devguide.python.org/#status-of-python-branches)
+ **Ruby** β [www\.ruby\-lang\.org](https://www.ruby-lang.org/en/downloads/branches/)
+ **Java** β [www\.oracle\.com](https://www.oracle.com/technetwork/java/java-se-support-roadmap.html) and [aws\.amazon\.com/corretto](https://aws.amazon.com/corretto/faqs/)
+ **Go** β [golang\.org](https://golang.org/s/release)
+ **\.NET Core** β [dotnet\.microsoft\.com](https://dotnet.microsoft.com/platform/support/policy/dotnet-core)
After a runtime is deprecated, Lambda might retire it completely at any time by disabling invocation\. Deprecated runtimes aren't eligible for security updates or technical support\. Before retiring a runtime, Lambda sends additional notifications to affected customers\. No runtimes are scheduled to be retired at this time\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtime-support-policy.md
|
abf35b416af7-0
|
Your Lambda function's handler is the method that Lambda calls when your function is invoked\. In the following example, the file `function.rb` defines a handler method named `handler`\. The handler function takes two objects as input and returns a JSON document\.
**Example function\.rb**
```
require 'json'
def handler(event:, context:)
{ event: JSON.generate(event), context: JSON.generate(context.inspect) }
end
```
In your function configuration, the `handler` setting tells Lambda where to find the handler\. For the preceding example, the correct value for this setting is **function\.handler**\. It includes two names separated by a dot: the name of the file and the name of the handler method\.
You can also define your handler method in a class\. The following example defines a handler method named `process` on a class named `Handler` in a module named `LambdaFunctions`\.
**Example source\.rb**
```
module LambdaFunctions
class Handler
def self.process(event:,context:)
"Hello!"
end
end
end
```
In this case, the handler setting is **source\.LambdaFunctions::Handler\.process**\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-handler.md
|
abf35b416af7-1
|
```
In this case, the handler setting is **source\.LambdaFunctions::Handler\.process**\.
The two objects that the handler accepts are the invocation event and context\. The event is a Ruby object that contains the payload that's provided by the invoker\. If the payload is a JSON document, the event object is a Ruby hash\. Otherwise, it's a string\. The [context object](ruby-context.md) has methods and properties that provide information about the invocation, the function, and the execution environment\.
The function handler is executed every time your Lambda function is invoked\. Static code outside of the handler is executed once per instance of the function\. If your handler uses resources like SDK clients and database connections, you can create them outside of the handler method to reuse them for multiple invocations\.
Each instance of your function can process multiple invocation events, but it only processes one event at a time\. The number of instances processing an event at any given time is your function's *concurrency*\. For more information about the Lambda execution context, see [AWS Lambda execution contextManaging state machines in the Lambda console](runtimes-context.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-handler.md
|
ccf97ff017d0-0
|
In this Getting Started exercise you create a Lambda function using the AWS Lambda console\. Next, you manually invoke the Lambda function using sample event data\. AWS Lambda executes the Lambda function and returns results\. You then verify execution results, including the logs that your Lambda function created and various CloudWatch metrics\.
**To create a Lambda function**
1. Open the [AWS Lambda console](https://console.aws.amazon.com/lambda/home)\.
1. Choose **Create a function**\.
1. For **Function name**, enter **my\-function**\.
1. Choose **Create function**\.
Lambda creates a Node\.js function and an execution role that grants the function permission to upload logs\. Lambda assumes the execution role when you invoke your function, and uses it to create credentials for the AWS SDK and to read data from event sources\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
26fb47c57250-0
|
The **Designer** shows an overview of your function and its upstream and downstream resources\. You can use it to configure triggers, layers, and destinations\.
![\[A Lambda function with an Amazon S3 trigger and Amazon EventBridge destination.\]](http://docs.aws.amazon.com/lambda/latest/dg/images/console-designer.png)
Choose **my\-function** in the designer to return to the function's code and configuration\. For scripting languages, Lambda includes sample code that returns a success response\. You can edit your function code with the embedded [AWS Cloud9](https://docs.aws.amazon.com/cloud9/latest/user-guide/) editor as long as your source code doesn't exceed the 3 MB limit\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
1424223b99f7-0
|
Invoke your Lambda function using the sample event data provided in the console\.
**To invoke a function**
1. In the upper right corner, choose **Test**\.
1. In the **Configure test event** page, choose **Create new test event** and in **Event template**, leave the default **Hello World** option\. Enter an **Event name** and note the following sample event template:
```
{
"key3": "value3",
"key2": "value2",
"key1": "value1"
}
```
You can change key and values in the sample JSON, but don't change the event structure\. If you do change any keys and values, you must update the sample code accordingly\.
1. Choose **Create** and then choose **Test**\. Each user can create up to 10 test events per function\. Those test events are not available to other users\.
1. AWS Lambda executes your function on your behalf\. The `handler` in your Lambda function receives and then processes the sample event\.
1. Upon successful execution, view results in the console\.
+ The **Execution result** section shows the execution status as **succeeded** and also shows the function execution results, returned by the `return` statement\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
1424223b99f7-1
|
+ The **Execution result** section shows the execution status as **succeeded** and also shows the function execution results, returned by the `return` statement\.
+ The **Summary** section shows the key information reported in the **Log output** section \(the *REPORT* line in the execution log\)\.
+ The **Log output** section shows the log AWS Lambda generates for each execution\. These are the logs written to CloudWatch by the Lambda function\. The AWS Lambda console shows these logs for your convenience\.
Note that the **Click here** link shows logs in the CloudWatch console\. The function then adds logs to Amazon CloudWatch in the log group that corresponds to the Lambda function\.
1. Run the Lambda function a few times to gather some metrics that you can view in the next step\.
1. From the tabs near the top of the page, choose **Monitoring**\. This page shows graphs for the metrics that Lambda sends to CloudWatch\.
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/metrics-functions-list.png)
For more information on these graphs, see [Monitoring functions in the AWS Lambda console](monitoring-functions-access-metrics.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
ddc5df678b7b-0
|
If you are done working with the example function, delete it\. You can also delete the execution role that the console created, and the log group that stores the function's logs\.
**To delete a Lambda function**
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
1. Choose a function\.
1. Choose **Actions**, and then choose **Delete function**\.
1. Choose **Delete**\.
**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-function`\)\.
1. Choose **Actions**, and then choose **Delete log group**\.
1. Choose **Yes, Delete**\.
**To delete the execution role**
1. Open the [Roles page](https://console.aws.amazon.com/iam/home?#/roles) of the AWS Identity and Access Management console\.
1. Choose the function's role \(`my-function-role-31exxmpl`\)
1. Choose **Delete role**\.
1. Choose **Yes, delete**\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
ddc5df678b7b-1
|
1. Choose **Delete role**\.
1. Choose **Yes, delete**\.
You can automate the creation and cleanup of functions, roles, and log groups with AWS CloudFormation and the AWS CLI\. For fully functional sample applications, see [Lambda sample applications](lambda-samples.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/getting-started-create-function.md
|
acf1700ba7ed-0
|
Adds a provisioned concurrency configuration to a function's alias or version\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
1a3def371c87-0
|
```
PUT /2019-09-30/functions/FunctionName/provisioned-concurrency?Qualifier=Qualifier HTTP/1.1
Content-type: application/json
{
"ProvisionedConcurrentExecutions": number
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
f3083b15512a-0
|
The request uses the following URI parameters\.
** [FunctionName](#API_PutProvisionedConcurrencyConfig_RequestSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-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\.
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
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
f3083b15512a-1
|
Required: Yes
** [Qualifier](#API_PutProvisionedConcurrencyConfig_RequestSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-request-Qualifier"></a>
The version number or alias name\.
Length Constraints: Minimum length of 1\. Maximum length of 128\.
Pattern: `(|[a-zA-Z0-9$_-]+)`
Required: Yes
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
58fe12f28aca-0
|
The request accepts the following data in JSON format\.
** [ProvisionedConcurrentExecutions](#API_PutProvisionedConcurrencyConfig_RequestSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-request-ProvisionedConcurrentExecutions"></a>
The amount of provisioned concurrency to allocate for the version or alias\.
Type: Integer
Valid Range: Minimum value of 1\.
Required: Yes
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
0ab9829ca227-0
|
```
HTTP/1.1 202
Content-type: application/json
{
"AllocatedProvisionedConcurrentExecutions": number,
"AvailableProvisionedConcurrentExecutions": number,
"LastModified": "string",
"RequestedProvisionedConcurrentExecutions": number,
"Status": "string",
"StatusReason": "string"
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
cfb05787bf97-0
|
If the action is successful, the service sends back an HTTP 202 response\.
The following data is returned in JSON format by the service\.
** [AllocatedProvisionedConcurrentExecutions](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-AllocatedProvisionedConcurrentExecutions"></a>
The amount of provisioned concurrency allocated\.
Type: Integer
Valid Range: Minimum value of 0\.
** [AvailableProvisionedConcurrentExecutions](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-AvailableProvisionedConcurrentExecutions"></a>
The amount of provisioned concurrency available\.
Type: Integer
Valid Range: Minimum value of 0\.
** [LastModified](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-LastModified"></a>
The date and time that a user last updated the configuration, in [ISO 8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
cfb05787bf97-1
|
Type: String
** [RequestedProvisionedConcurrentExecutions](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-RequestedProvisionedConcurrentExecutions"></a>
The amount of provisioned concurrency requested\.
Type: Integer
Valid Range: Minimum value of 1\.
** [Status](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-Status"></a>
The status of the allocation process\.
Type: String
Valid Values:` IN_PROGRESS | READY | FAILED`
** [StatusReason](#API_PutProvisionedConcurrencyConfig_ResponseSyntax) ** <a name="SSS-PutProvisionedConcurrencyConfig-response-StatusReason"></a>
For failed allocations, the reason that provisioned concurrency could not be allocated\.
Type: String
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
5b513a15e97a-0
|
**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_PutProvisionedConcurrencyConfig.md
|
91c580f2c846-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/PutProvisionedConcurrencyConfig)
+ [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
91c580f2c846-1
|
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/PutProvisionedConcurrencyConfig)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_PutProvisionedConcurrencyConfig.md
|
920569b32b9f-0
|
You can create a web API with an HTTP endpoint for your Lambda function by using Amazon API Gateway\. API Gateway provides tools for creating and documenting web APIs that route HTTP requests to Lambda functions\. You can secure access to your API with authentication and authorization controls\. Your APIs can serve traffic over the internet or can be accessible only within your VPC\.
**To add a public endpoint to your Lambda function**
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
1. Choose a function\.
1. Under **Designer**, choose **Add trigger**\.
1. Choose **API Gateway**\.
1. For **API**, choose **Create an API**\.
1. For **Security**, choose **Open**\.
1. Choose **Add**\.
With the **API Gateway** trigger selected in the designer, choose the endpoint to invoke the function with API Gateway\.
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/console-apig-endpoint.png)
API Gateway APIs are comprised of stages, resources, methods, and integrations\. The stage and resource determine the path of the endpoint:
**API path format**
+ `/prod/` β The `prod` stage and root resource\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-1
|
**API path format**
+ `/prod/` β The `prod` stage and root resource\.
+ `/prod/user` β The `prod` stage and `user` resource\.
+ `/dev/{proxy+}` β Any route in the `dev` stage\.
+ `/` β \(HTTP APIs\) The default stage and root resource\.
A Lambda integration maps a path and HTTP method combination to a Lambda function\. You can configure API Gateway to pass the body of the HTTP request as\-is \(custom integration\), or to encapsulate the request body in a document that includes all of the request information including headers, resource, path, and method\.
Amazon API Gateway invokes your function [synchronously](invocation-sync.md) with an event that contains a JSON representation of the HTTP request\. For a custom integration, the event is the body of the request\. For a proxy integration, the event has a defined structure\. The following example shows a proxy event from an API Gateway REST API\.
**Example [event\.json](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/nodejs-apig/event.json) API Gateway proxy event \(REST API\)**
```
{
"resource": "/",
"path": "/",
"httpMethod": "GET",
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-2
|
"resource": "/",
"path": "/",
"httpMethod": "GET",
"requestContext": {
"resourcePath": "/",
"httpMethod": "GET",
"path": "/Prod/",
...
},
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
"Host": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-5e66d96f-7491f09xmpl79d18acf3d050",
...
},
"multiValueHeaders": {
"accept": [
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-3
|
...
},
"multiValueHeaders": {
"accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
],
"accept-encoding": [
"gzip, deflate, br"
],
...
},
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"body": null,
"isBase64Encoded": false
}
```
This example shows an event for a GET request to the root path of the Prod stage of a REST API\. Event shape and contents vary by [API type](#services-apigateway-apitypes) and configuration\.
API Gateway waits for a response from your function and relays the result to the caller\. For a custom integration, you define an integration response and a method response to convert the output from the function to an HTTP response\. For a proxy integration, the function must respond with a representation of the response in a specific format\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-4
|
The following example shows a response object from a Node\.js function\. The response object represents a successful HTTP response that contains a JSON document\.
**Example [index\.js](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/nodejs-apig/function/index.js) β Proxy integration response object \(Node\.js\)**
```
var response = {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"isBase64Encoded": false,
"multiValueHeaders": {
"X-Custom-Header": ["My value", "My other value"],
},
"body": "{\n \"TotalCodeSize\": 104330022,\n \"FunctionCount\": 26\n}"
}
```
The Lambda runtime serializes the response object into JSON and sends it to the API\. The API parses the response and uses it to create an HTTP response, which it then sends to the client that made the original request\.
**Example HTTP response**
```
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 55
< Connection: keep-alive
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-5
|
< Content-Type: application/json
< Content-Length: 55
< Connection: keep-alive
< x-amzn-RequestId: 32998fea-xmpl-4268-8c72-16138d629356
< X-Custom-Header: My value
< X-Custom-Header: My other value
< X-Amzn-Trace-Id: Root=1-5e6aa925-ccecxmplbae116148e52f036
<
{
"TotalCodeSize": 104330022,
"FunctionCount": 26
}
```
Resources in your API define one or more methods, such as GET or POST\. Methods have an integration that routes requests to a Lambda function or another integration type\. You can define each resource and method individually, or use special resource and method types to match all requests that fit a pattern\. A *proxy resource* catches all paths beneath a resource\. The `ANY` method catches all HTTP methods\.
**Topics**
+ [Permissions](#apigateway-permissions)
+ [Handling errors with an API Gateway API](#services-apigateway-errors)
+ [Choosing an API type](#services-apigateway-apitypes)
+ [Sample applications](#services-apigateway-samples)
+ [Tutorial: Using AWS Lambda with Amazon API Gateway](services-apigateway-tutorial.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
920569b32b9f-6
|
+ [Tutorial: Using AWS Lambda with Amazon API Gateway](services-apigateway-tutorial.md)
+ [Sample function code](services-apigateway-code.md)
+ [Create a simple microservice using Lambda and API Gateway](services-apigateway-blueprint.md)
+ [AWS SAM template for an API Gateway application](services-apigateway-template.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
ce725aff3484-0
|
Amazon API Gateway gets permission to invoke your function from the function's [resource\-based policy](access-control-resource-based.md)\. You can grant invoke permission to an entire API, or grant limited access to a stage, resource, or method\.
When you add an API to your function by using the Lambda console, using the API Gateway console, or in an AWS SAM template, the function's resource\-based policy is updated automatically\. The following example shows a function policy with a statement that was added by an AWS SAM template\.
**Example function policy**
```
{
"Version": "2012-10-17",
"Id": "default",
"Statement": [
{
"Sid": "nodejs-apig-functiongetEndpointPermissionProd-BWDBXMPLXE2F",
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:us-east-2:123456789012:function:nodejs-apig-function-1G3MXMPLXVXYI",
"Condition": {
"ArnLike": {
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
ce725aff3484-1
|
"Condition": {
"ArnLike": {
"AWS:SourceArn": "arn:aws:execute-api:us-east-2:123456789012:ktyvxmpls1/*/GET/"
}
}
}
]
}
```
[Confirm the function policy](access-control-resource-based.md) in the **Permissions** tab of the Lambda console\.
You can manage function policy permissions manually with the following API operations:
+ [AddPermission](API_AddPermission.md)
+ [RemovePermission](API_RemovePermission.md)
+ [GetPolicy](API_GetPolicy.md)
To grant invocation permission to an existing API, use the `add-permission` command\.
```
$ aws lambda add-permission --function-name my-function \
--statement-id apigateway-get --action lambda:InvokeFunction \
--principal apigateway.amazonaws.com \
--source-arn "arn:aws:execute-api:us-east-2:123456789012:mnh1xmpli7/default/GET/"
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
ce725aff3484-2
|
{
"Statement": "{\"Sid\":\"apigateway-test-2\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"apigateway.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:function:my-function\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:execute-api:us-east-2:123456789012:mnh1xmpli7/default/GET\"}}}"
}
```
**Note**
If your function and API are in different regions, the region identifier in the source ARN must match the region of the function, not the region of the API\. When API Gateway invokes a function, it uses a resource ARN that is based on the ARN of the API, but modified to match the function's region\.
The source ARN in this example grants permission to an integration on the GET method of the root resource in the default stage of an API, with ID `mnh1xmpli7`\. You can use an asterisk in the source ARN to grant permissions to multiple stages, methods, or resources\.
**Resource patterns**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
ce725aff3484-3
|
**Resource patterns**
+ `mnh1xmpli7/*/GET/*` β GET method on all resources in all stages\.
+ `mnh1xmpli7/prod/ANY/user` β ANY method on the `user` resource in the `prod` stage\.
+ `mnh1xmpli7/*/*/*` β Any method on all resources in all stages\.
For details on viewing the policy and removing statements, see [Cleaning up resource\-based policies](access-control-resource-based.md#permissions-resource-cleanup)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
91bf28f0af63-0
|
API Gateway treats all invocation and function errors as internal errors\. If the Lambda API rejects the invocation request, API Gateway returns a 500 error code\. If the function runs but returns an error, or returns a response in the wrong format, API Gateway returns a 502\. In both cases, the body of the response from API Gateway is `{"message": "Internal server error"}`\.
The following example shows an X\-Ray trace map for a request that resulted in a function error and a 502 from API Gateway\. The client receives the generic error message\.
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/tracemap-apig-502.png)
To customize the error response, you must catch errors in your code and format a response in the required format\.
**Example [index\.js](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/nodejs-apig/function/index.js) β Error formatting**
```
var formatError = function(error){
var response = {
"statusCode": error.statusCode,
"headers": {
"Content-Type": "text/plain",
"x-amzn-ErrorType": error.code
},
"isBase64Encoded": false,
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
91bf28f0af63-1
|
"x-amzn-ErrorType": error.code
},
"isBase64Encoded": false,
"body": error.code + ": " + error.message
}
return response
}
```
API Gateway converts this response into an HTTP error with a custom status code and body\. In the trace map, the function node is green because it handled the error\.
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/tracemap-apig-404.png)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
fc51b92afbbc-0
|
API Gateway supports three types of APIs that invoke Lambda functions:
+ **HTTP API** β A lightweight, low\-latency RESTful API\.
+ **REST API** β A customizable, feature\-rich RESTful API\.
+ **WebSocket API** β A web API that maintains persistent connections with clients for full\-duplex communication\.
HTTP APIs and REST APIs are both RESTful APIs that process HTTP requests and return responses\. HTTP APIs are newer and are built with the API Gateway version 2 API\. The following features are new for HTTP APIs:
**HTTP API features**
+ **Automatic deployments** β When you modify routes or integrations, changes deploy automatically to stages that have automatic deployment enabled\.
+ **Default stage** β You can create a default stage \(`$default`\) to serve requests at the root path of your API's URL\. For named stages, you must include the stage name at the beginning of the path\.
+ **CORS configuration** β You can configure your API to add CORS headers to outgoing responses, instead of adding them manually in your function code\.
REST APIs are the classic RESTful APIs that API Gateway has supported since launch\. REST APIs currently have more customization, integration, and management features\.
**REST API features**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
fc51b92afbbc-1
|
**REST API features**
+ **Integration types** β REST APIs support custom Lambda integrations\. With a custom integration, you can send just the body of the request to the function, or apply a transform template to the request body before sending it to the function\.
+ **Access control** β REST APIs support more options for authentication and authorization\.
+ **Monitoring and tracing** β REST APIs support AWS X\-Ray tracing and additional logging options\.
For a detailed comparison, see [Choosing between HTTP APIs and REST APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html) in the *API Gateway Developer Guide*\.
WebSocket APIs also use the API Gateway version 2 API and support a similar feature set\. Use a WebSocket API for applications that benefit from a persistent connection between the client and API\. WebSocket APIs provide full\-duplex communication, which means that both the client and the API can send messages continuously without waiting for a response\.
HTTP APIs support a simplified event format \(version 2\.0\)\. The following example shows an event from an HTTP API\.
**Example [event\-v2\.json](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/nodejs-apig/event-v2.json) β API Gateway proxy event \(HTTP API\)**
```
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
fc51b92afbbc-2
|
```
{
"version": "2.0",
"routeKey": "ANY /nodejs-apig-function-1G3XMPLZXVXYI",
"rawPath": "/default/nodejs-apig-function-1G3XMPLZXVXYI",
"rawQueryString": "",
"cookies": [
"s_fid=7AABXMPL1AFD9BBF-0643XMPL09956DE2",
"regStatus=pre-register"
],
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
...
},
"requestContext": {
"accountId": "123456789012",
"apiId": "r3pmxmplak",
"domainName": "r3pmxmplak.execute-api.us-east-2.amazonaws.com",
"domainPrefix": "r3pmxmplak",
"http": {
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
fc51b92afbbc-3
|
"domainPrefix": "r3pmxmplak",
"http": {
"method": "GET",
"path": "/default/nodejs-apig-function-1G3XMPLZXVXYI",
"protocol": "HTTP/1.1",
"sourceIp": "205.255.255.176",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"
},
"requestId": "JKJaXmPLvHcESHA=",
"routeKey": "ANY /nodejs-apig-function-1G3XMPLZXVXYI",
"stage": "default",
"time": "10/Mar/2020:05:16:23 +0000",
"timeEpoch": 1583817383220
},
"isBase64Encoded": true
}
```
For more information, see [AWS Lambda integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html) in the API Gateway Developer Guide\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
82046df6a12c-0
|
The GitHub repository for this guide provides the following sample application for API Gateway\.
+ [API Gateway with Node\.js](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/nodejs-apig) β A function with an AWS SAM template that creates a REST API that has AWS X\-Ray tracing enabled\. It includes scripts for deploying, invoking the function, testing the API, and cleanup\.
Lambda also provides [blueprints](gettingstarted-features.md#gettingstarted-features-blueprints) and [templates](gettingstarted-features.md#gettingstarted-features-templates) that you can use to create an API Gateway application in the Lambda console\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/services-apigateway.md
|
d8911e59962c-0
|
Returns details about a Lambda function [alias](https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
8c267b62c6c3-0
|
```
GET /2015-03-31/functions/FunctionName/aliases/Name HTTP/1.1
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
43606784f490-0
|
The request uses the following URI parameters\.
** [FunctionName](#API_GetAlias_RequestSyntax) ** <a name="SSS-GetAlias-request-FunctionName"></a>
The name of the Lambda function\.
**Name formats**
+ **Function name** \- `MyFunction`\.
+ **Function ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:MyFunction`\.
+ **Partial ARN** \- `123456789012:function:MyFunction`\.
The length constraint applies only to the full ARN\. If you specify only the function name, it is limited to 64 characters in length\.
Length Constraints: Minimum length of 1\. Maximum length of 140\.
Pattern: `(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?`
Required: Yes
** [Name](#API_GetAlias_RequestSyntax) ** <a name="SSS-GetAlias-request-Name"></a>
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
43606784f490-1
|
The name of the alias\.
Length Constraints: Minimum length of 1\. Maximum length of 128\.
Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)`
Required: Yes
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
61185c544683-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_GetAlias.md
|
1c8947b93262-0
|
```
HTTP/1.1 200
Content-type: application/json
{
"AliasArn": "string",
"Description": "string",
"FunctionVersion": "string",
"Name": "string",
"RevisionId": "string",
"RoutingConfig": {
"AdditionalVersionWeights": {
"string" : number
}
}
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
45743db0d14c-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\.
** [AliasArn](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-AliasArn"></a>
The Amazon Resource Name \(ARN\) of the alias\.
Type: String
Pattern: `arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_]+(:(\$LATEST|[a-zA-Z0-9-_]+))?`
** [Description](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-Description"></a>
A description of the alias\.
Type: String
Length Constraints: Minimum length of 0\. Maximum length of 256\.
** [FunctionVersion](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-FunctionVersion"></a>
The function version that the alias invokes\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 1024\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
45743db0d14c-1
|
The function version that the alias invokes\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 1024\.
Pattern: `(\$LATEST|[0-9]+)`
** [Name](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-Name"></a>
The name of the alias\.
Type: String
Length Constraints: Minimum length of 1\. Maximum length of 128\.
Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)`
** [RevisionId](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-RevisionId"></a>
A unique identifier that changes when you update the alias\.
Type: String
** [RoutingConfig](#API_GetAlias_ResponseSyntax) ** <a name="SSS-GetAlias-response-RoutingConfig"></a>
The [routing configuration](https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html) of the alias\.
Type: [AliasRoutingConfiguration](API_AliasRoutingConfiguration.md) object
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
3323a7afb58b-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_GetAlias.md
|
a9ca33099681-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/GetAlias)
+ [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/GetAlias)
+ [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/GetAlias)
+ [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/GetAlias)
+ [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/GetAlias)
+ [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/GetAlias)
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/GetAlias)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
a9ca33099681-1
|
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/GetAlias)
+ [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/GetAlias)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetAlias.md
|
8ffccff071b9-0
|
You can implement an AWS Lambda runtime in any programming language\. A runtime is a program that runs a Lambda function's handler method when the function is invoked\. You can include a runtime in your function's deployment package in the form of an executable file named `bootstrap`\.
A runtime is responsible for running the function's setup code, reading the handler name from an environment variable, and reading invocation events from the Lambda runtime API\. The runtime passes the event data to the function handler, and posts the response from the handler back to Lambda\.
Your custom runtime runs in the standard Lambda [execution environment](lambda-runtimes.md)\. It can be a shell script, a script in a language that's included in Amazon Linux, or a binary executable file that's compiled in Amazon Linux\.
To get started with custom runtimes, see [Tutorial β Publishing a custom runtime](runtimes-walkthrough.md)\. You can also explore a custom runtime implemented in C\+\+ at [awslabs/aws\-lambda\-cpp](https://github.com/awslabs/aws-lambda-cpp) on GitHub\.
**Topics**
+ [Using a custom runtime](#runtimes-custom-use)
+ [Building a custom runtime](#runtimes-custom-build)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
5c4be02feafc-0
|
To use a custom runtime, set your function's runtime to `provided`\. The runtime can be included in your function's deployment package, or in a [layer](configuration-layers.md)\.
**Example function\.zip**
```
.
βββ bootstrap
βββ function.sh
```
If there's a file named `bootstrap` in your deployment package, Lambda executes that file\. If not, Lambda looks for a runtime in the function's layers\. If the bootstrap file isn't found or isn't executable, your function returns an error upon invocation\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
9004fb4d7c26-0
|
A custom runtime's entry point is an executable file named `bootstrap`\. The bootstrap file can be the runtime, or it can invoke another file that creates the runtime\. The following example uses a bundled version of Node\.js to execute a JavaScript runtime in a separate file named `runtime.js`\.
**Example bootstrap**
```
#!/bin/sh
cd $LAMBDA_TASK_ROOT
./node-v11.1.0-linux-x64/bin/node runtime.js
```
Your runtime code is responsible for completing some initialization tasks\. Then it processes invocation events in a loop until it's terminated\. The initialization tasks run once [per instance of the function](runtimes-context.md) to prepare the environment to handle invocations\.
**Initialization tasks**
+ **Retrieve settings** β Read environment variables to get details about the function and environment\.
+ `_HANDLER` β The location to the handler, from the function's configuration\. The standard format is `file.method`, where `file` is the name of the file without an extension, and `method` is the name of a method or function that's defined in the file\.
+ `LAMBDA_TASK_ROOT` β The directory that contains the function code\.
+ `AWS_LAMBDA_RUNTIME_API` β The host and port of the runtime API\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
9004fb4d7c26-1
|
+ `AWS_LAMBDA_RUNTIME_API` β The host and port of the runtime API\.
See [Runtime environment variables](configuration-envvars.md#configuration-envvars-runtime) for a full list of available variables\.
+ **Initialize the function** β Load the handler file and run any global or static code that it contains\. Functions should create static resources like SDK clients and database connections once, and reuse them for multiple invocations\.
+ **Handle errors** β If an error occurs, call the [initialization error](runtimes-api.md#runtimes-api-initerror) API and exit immediately\.
Initialization counts towards billed execution time and timeout\. When an execution triggers the initialization of a new instance of your function, you can see the initialization time in the logs and [AWS X\-Ray trace](services-xray.md)\.
**Example log**
```
REPORT RequestId: f8ac1208... Init Duration: 48.26 ms Duration: 237.17 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 26 MB
```
![\[Initialization time in an X-Ray trace.\]](http://docs.aws.amazon.com/lambda/latest/dg/images/runtimes-custom-init.png)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
9004fb4d7c26-2
|
While it runs, a runtime uses the [Lambda runtime interface](runtimes-api.md) to manage incoming events and report errors\. After completing initialization tasks, the runtime processes incoming events in a loop\. In your runtime code, perform the following steps in order\.
**Processing tasks**
+ **Get an event** β Call the [next invocation](runtimes-api.md#runtimes-api-next) API to get the next event\. The response body contains the event data\. Response headers contain the request ID and other information\.
+ **Propagate the tracing header** β Get the X\-Ray tracing header from the `Lambda-Runtime-Trace-Id` header in the API response\. Set the `_X_AMZN_TRACE_ID` environment variable locally with the same value\. The X\-Ray SDK uses this value to connect trace data between services\.
+ **Create a context object** β Create an object with context information from environment variables and headers in the API response\.
+ **Invoke the function handler** β Pass the event and context object to the handler\.
+ **Handle the response** β Call the [invocation response](runtimes-api.md#runtimes-api-response) API to post the response from the handler\.
+ **Handle errors** β If an error occurs, call the [invocation error](runtimes-api.md#runtimes-api-invokeerror) API\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
9004fb4d7c26-3
|
+ **Cleanup** β Release unused resources, send data to other services, or perform additional tasks before getting the next event\.
You can include the runtime in your function's deployment package, or distribute the runtime separately in a function layer\. For an example walkthrough, see [Tutorial β Publishing a custom runtime](runtimes-walkthrough.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-custom.md
|
d0d0f383fa70-0
|
Lambda integrates with AWS X\-Ray to enable you to trace, debug, and optimize Lambda applications\. You can use X\-Ray to trace a request as it traverses resources in your application, from the frontend API to storage and database on the backend\. By simply adding the X\-Ray SDK library to your build configuration, you can record errors and latency for any call that your function makes to an AWS service\.
The X\-Ray *service map* shows the flow of requests through your application\. The following example from the [error processor](samples-errorprocessor.md) sample application shows an application with two functions\. The primary function processes events and sometimes returns errors\. The second function processes errors that appear in the first's log group and uses the AWS SDK to call X\-Ray, Amazon S3 and Amazon CloudWatch Logs\.
[images/sample-errorprocessor-servicemap-l.png](images/sample-errorprocessor-servicemap-l.png)
To trace requests that don't have a tracing header, enable active tracing in your function's configuration\.
**To enable active tracing**
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
1. Choose a function\.
1. Under **AWS X\-Ray**, choose **Active tracing**\.
1. Choose **Save**\.
**Pricing**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
d0d0f383fa70-1
|
1. Choose **Save**\.
**Pricing**
X\-Ray has a perpetual free tier\. Beyond the free tier threshold, X\-Ray charges for trace storage and retrieval\. For details, see [AWS X\-Ray pricing](https://aws.amazon.com/xray/pricing/)\.
Your function needs permission to upload trace data to X\-Ray\. When you enable active tracing in the Lambda console, Lambda adds the required permissions to your function's [execution role](lambda-intro-execution-role.md)\. Otherwise, add the [AWSXRayDaemonWriteAccess](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess) policy to the execution role\.
X\-Ray applies a sampling algorithm to ensure that tracing is efficient, while still providing a representative sample of the requests that your application serves\. The default sampling rule is 1 request per second and 5 percent of additional requests\. This sampling rate cannot be configured for Lambda functions\.
When active tracing is enabled, Lambda records a trace for a subset of invocations\. Lambda records two *segments*, which creates two nodes on the service map\. The first node represents the Lambda service that receives the invocation request\. The second node is recorded by the function's [runtime](gettingstarted-concepts.md#gettingstarted-concepts-runtimes)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
d0d0f383fa70-2
|
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/xray-servicemap-function.png)
You can instrument your handler code to record metadata and trace downstream calls\. To record detail about calls that your handler makes to other resources and services, use the X\-Ray SDK for Node\.js\. To get the SDK, add the `aws-xray-sdk-core` package to your application's dependencies\.
**Example [blank\-nodejs/package\.json](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/package.json)**
```
{
"name": "blank-nodejs",
"version": "1.0.0",
"private": true,
"devDependencies": {
"aws-sdk": "2.631.0",
"jest": "25.4.0"
},
"dependencies": {
"aws-xray-sdk-core": "1.1.2"
},
"scripts": {
"test": "jest"
}
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
d0d0f383fa70-3
|
"scripts": {
"test": "jest"
}
}
```
To instrument AWS SDK clients, wrap the `aws-sdk` library with the `captureAWS` method\.
**Example [blank\-nodejs/function/index\.js](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/function/index.js) β Tracing an AWS SDK client**
```
const AWSXRay = require('aws-xray-sdk-core')
const AWS = AWSXRay.captureAWS(require('aws-sdk'))
// Create client outside of handler to reuse
const lambda = new AWS.Lambda()
// Handler
exports.handler = async function(event, context) {
event.Records.forEach(record => {
...
```
The following example shows a trace with 2 segments\. Both are named **my\-function**, but one is type `AWS::Lambda` and the other is `AWS::Lambda::Function`\. The function segment is expanded to show its subsegments\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
d0d0f383fa70-4
|
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/nodejs-xray-timeline.png)
The first segment represents the invocation request processed by the Lambda service\. The second segment records the work done by your function\. The function segment has 3 subsegments\.
+ **Initialization** β Represents time spent loading your function and running [initialization code](gettingstarted-features.md#gettingstarted-features-programmingmodel)\. This subsegment only appears for the first event processed by each instance of your function\.
+ **Invocation** β Represents the work done by your handler code\. By instrumenting your code, you can extend this subsegment with additional subsegments\.
+ **Overhead** β Represents the work done by the Lambda runtime to prepare to handle the next event\.
You can also instrument HTTP clients, record SQL queries, and create custom subsegments with annotations and metadata\. For more information, see [The X\-Ray SDK for Node\.js](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs.html) in the AWS X\-Ray Developer Guide\.
**Topics**
+ [Enabling active tracing with the Lambda API](#nodejs-tracing-api)
+ [Enabling active tracing with AWS CloudFormation](#nodejs-tracing-cloudformation)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
d0d0f383fa70-5
|
+ [Enabling active tracing with AWS CloudFormation](#nodejs-tracing-cloudformation)
+ [Storing runtime dependencies in a layer](#nodejs-tracing-layers)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
b368691078b8-0
|
To manage tracing configuration with the AWS CLI or AWS SDK, use the following API operations:
+ [UpdateFunctionConfiguration](API_UpdateFunctionConfiguration.md)
+ [GetFunctionConfiguration](API_GetFunctionConfiguration.md)
+ [CreateFunction](API_CreateFunction.md)
The following example AWS CLI command enables active tracing on a function named my\-function\.
```
$ aws lambda update-function-configuration --function-name my-function \
--tracing-config Mode=Active
```
Tracing mode is part of the version\-specific configuration that is locked when you publish a version of your function\. You can't change the tracing mode on a published version\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
8195895bceff-0
|
To enable active tracing on an `AWS::Lambda::Function` resource in an AWS CloudFormation template, use the `TracingConfig` property\.
**Example [function\-inline\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/templates/function-inline.yml) β Tracing configuration**
```
Resources:
function:
Type: [AWS::Lambda::Function](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html)
Properties:
TracingConfig:
Mode: Active
...
```
For an AWS Serverless Application Model \(AWS SAM\) `AWS::Serverless::Function` resource, use the `Tracing` property\.
**Example [template\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/template.yml) β Tracing configuration**
```
Resources:
function:
Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html)
Properties:
Tracing: Active
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
8195895bceff-1
|
Properties:
Tracing: Active
...
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
5721b6fb2f65-0
|
If you use the X\-Ray SDK to instrument AWS SDK clients your function code, your deployment package can become quite large\. To avoid uploading runtime dependencies every time you update your functions code, package them in a [Lambda layer](configuration-layers.md)\.
The following example shows an `AWS::Serverless::LayerVersion` resource that stores X\-Ray SDK for Node\.js\.
**Example [template\.yml](https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/blank-nodejs/template.yml) β Dependencies layer**
```
Resources:
function:
Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html)
Properties:
CodeUri: function/.
Tracing: Active
Layers:
- !Ref libs
...
libs:
Type: [AWS::Serverless::LayerVersion](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html)
Properties:
LayerName: blank-nodejs-lib
Description: Dependencies for the blank sample app.
ContentUri: lib/.
CompatibleRuntimes:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
5721b6fb2f65-1
|
Description: Dependencies for the blank sample app.
ContentUri: lib/.
CompatibleRuntimes:
- nodejs12.x
```
With this configuration, you only update library layer if you change your runtime dependencies\. The function deployment package only contains your code\. When you update your function code, upload time is much faster than if you include dependencies in the deployment package\.
Creating a layer for dependencies requires build changes to generate the layer archive prior to deployment\. For a working example, see the [blank\-nodejs](https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/sample-apps/blank-nodejs) sample application\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/nodejs-tracing.md
|
8da2113cc342-0
|
You can build this application using [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/)\. To learn more about creating AWS SAM templates, see [ AWS SAM template basics](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html) in the *AWS Serverless Application Model Developer Guide*\.
Below is a sample AWS SAM template for the [tutorial application](with-ddb-example.md)\. Copy the text below to a \.yaml file and save it next to the ZIP package you created previously\. Note that the `Handler` and `Runtime` parameter values should match the ones you used when you created the function in the previous section\.
**Example template\.yaml**
```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
ProcessDynamoDBStream:
Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html)
Properties:
Handler: handler
Runtime: runtime
Policies: AWSLambdaDynamoDBExecutionRole
Events:
Stream:
Type: DynamoDB
Properties:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/kinesis-tutorial-spec.md
|
8da2113cc342-1
|
Events:
Stream:
Type: DynamoDB
Properties:
Stream: !GetAtt DynamoDBTable.StreamArn
BatchSize: 100
StartingPosition: TRIM_HORIZON
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
StreamSpecification:
StreamViewType: NEW_IMAGE
```
For information on how to package and deploy your serverless application using the package and deploy commands, see [Deploying serverless applications](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-deploying.html) in the *AWS Serverless Application Model Developer Guide*\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/kinesis-tutorial-spec.md
|
78b7c867f0cc-0
|
Your Lambda function comes with a CloudWatch Logs log group, with a log stream for each instance of your function\. The runtime sends details about each invocation to the log stream, and relays logs and other output from your function's code\.
To output logs from your function code, you can use [the `print` method](https://docs.python.org/3/library/functions.html#print), or any logging library that writes to `stdout` or `stderr`\. The following example logs the values of environment variables and the event object\.
**Example lambda\_function\.py**
```
import os
def lambda_handler(event, context):
print('## ENVIRONMENT VARIABLES')
print(os.environ)
print('## EVENT')
print(event)
```
**Example log format**
```
START RequestId: 8f507cfc-xmpl-4697-b07a-ac58fc914c95 Version: $LATEST
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
d3ddcca79354-0
|
environ({'AWS_LAMBDA_LOG_GROUP_NAME': '/aws/lambda/my-function', 'AWS_LAMBDA_LOG_STREAM_NAME': '2020/01/31/[$LATEST]3893xmpl7fac4485b47bb75b671a283c', 'AWS_LAMBDA_FUNCTION_NAME': 'my-function', ...})
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
c6412482ee3a-0
|
{'key': 'value'}
END RequestId: 8f507cfc-xmpl-4697-b07a-ac58fc914c95
REPORT RequestId: 8f507cfc-xmpl-4697-b07a-ac58fc914c95 Duration: 15.74 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 56 MB Init Duration: 130.49 ms
XRAY TraceId: 1-5e34a614-10bdxmplf1fb44f07bc535a1 SegmentId: 07f5xmpl2d1f6f85 Sampled: true
```
The Python runtime logs the `START`, `END`, and `REPORT` lines for each invocation\. The report line provides the following details\.
**Report Log**
+ **RequestId** β The unique request ID for the invocation\.
+ **Duration** β The amount of time that your function's handler method spent processing the event\.
+ **Billed Duration** β The amount of time billed for the invocation\.
+ **Memory Size** β The amount of memory allocated to the function\.
+ **Max Memory Used** β The amount of memory used by the function\.
+ **Init Duration** β For the first request served, the amount of time it took the runtime to load the function and run code outside of the handler method\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
c6412482ee3a-1
|
+ **Init Duration** β For the first request served, the amount of time it took the runtime to load the function and run code outside of the handler method\.
+ **XRAY TraceId** β For traced requests, the [AWS X\-Ray trace ID](services-xray.md)\.
+ **SegmentId** β For traced requests, the X\-Ray segment ID\.
+ **Sampled** β For traced requests, the sampling result\.
You can view logs in the Lambda console, in the CloudWatch Logs console, or from the command line\.
**Topics**
+ [Viewing logs in the AWS Management Console](#python-logging-console)
+ [Using the AWS CLI](#python-logging-cli)
+ [Deleting logs](#python-logging-delete)
+ [Logging library](#python-logging-lib)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
39a9a4c6f06d-0
|
The Lambda console shows log output when you test a function on the function configuration page\. To view logs for all invocations, use the CloudWatch Logs console\.
**To view your Lambda function's logs**
1. Open the [Logs page of the CloudWatch console](https://console.aws.amazon.com/cloudwatch/home?#logs:)\.
1. Choose the log group for your function \(**/aws/lambda/*function\-name***\)\.
1. Choose the first stream in the list\.
Each log stream corresponds to an [instance of your function](runtimes-context.md)\. New streams appear when you update your function and when additional instances are created to handle multiple concurrent invocations\. To find logs for specific invocations, you can instrument your function with X\-Ray, and record details about the request and log stream in the trace\. For a sample application that correlates logs and traces with X\-Ray, 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/python-logging.md
|
e30579b67b76-0
|
To get logs for an invocation from the command line, use the `--log-type` option\. The response includes a `LogResult` field that contains up to 4 KB of base64\-encoded logs from the invocation\.
```
$ aws lambda invoke --function-name my-function out --log-type Tail
{
"StatusCode": 200,
"LogResult": "U1RBUlQgUmVxdWVzdElkOiA4N2QwNDRiOC1mMTU0LTExZTgtOGNkYS0yOTc0YzVlNGZiMjEgVmVyc2lvb...",
"ExecutedVersion": "$LATEST"
}
```
You can use the `base64` utility to decode the logs\.
```
$ aws lambda invoke --function-name my-function out --log-type Tail \
--query 'LogResult' --output text | base64 -d
START RequestId: 57f231fb-1730-4395-85cb-4f71bd2b87b8 Version: $LATEST
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
e30579b67b76-1
|
START RequestId: 57f231fb-1730-4395-85cb-4f71bd2b87b8 Version: $LATEST
"AWS_SESSION_TOKEN": "AgoJb3JpZ2luX2VjELj...", "_X_AMZN_TRACE_ID": "Root=1-5d02e5ca-f5792818b6fe8368e5b51d50;Parent=191db58857df8395;Sampled=0"",ask/lib:/opt/lib",
END RequestId: 57f231fb-1730-4395-85cb-4f71bd2b87b8
REPORT RequestId: 57f231fb-1730-4395-85cb-4f71bd2b87b8 Duration: 79.67 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 73 MB
```
The `base64` utility is available on Linux, macOS, and [Ubuntu on Windows](https://docs.microsoft.com/en-us/windows/wsl/install-win10)\. For macOS, the command is `base64 -D`\.
To get full log events from the command line, you can include the log stream name in the output of your function, as shown in the preceding example\. The following example script invokes a function named `my-function` and downloads the last five log events\.
**Example get\-logs\.sh Script**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
e30579b67b76-2
|
**Example get\-logs\.sh Script**
This example requires that `my-function` returns a log stream ID\.
```
#!/bin/bash
aws lambda invoke --function-name my-function --payload '{"key": "value"}' out
sed -i'' -e 's/"//g' out
sleep 15
aws logs get-log-events --log-group-name /aws/lambda/my-function --log-stream-name $(cat out) --limit 5
```
The script uses `sed` to remove quotes from the output file, and sleeps for 15 seconds to allow time for the logs to be available\. The output includes the response from Lambda and the output from the `get-log-events` command\.
```
$ ./get-logs.sh
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
{
"events": [
{
"timestamp": 1559763003171,
"message": "START RequestId: 4ce9340a-b765-490f-ad8a-02ab3415e2bf Version: $LATEST\n",
"ingestionTime": 1559763003309
},
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
e30579b67b76-3
|
"ingestionTime": 1559763003309
},
{
"timestamp": 1559763003173,
"message": "2019-06-05T19:30:03.173Z\t4ce9340a-b765-490f-ad8a-02ab3415e2bf\tINFO\tENVIRONMENT VARIABLES\r{\r \"AWS_LAMBDA_FUNCTION_VERSION\": \"$LATEST\",\r ...",
"ingestionTime": 1559763018353
},
{
"timestamp": 1559763003173,
"message": "2019-06-05T19:30:03.173Z\t4ce9340a-b765-490f-ad8a-02ab3415e2bf\tINFO\tEVENT\r{\r \"key\": \"value\"\r}\n",
"ingestionTime": 1559763018353
},
{
"timestamp": 1559763003218,
"message": "END RequestId: 4ce9340a-b765-490f-ad8a-02ab3415e2bf\n",
"ingestionTime": 1559763018353
},
{
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
e30579b67b76-4
|
"ingestionTime": 1559763018353
},
{
"timestamp": 1559763003218,
"message": "REPORT RequestId: 4ce9340a-b765-490f-ad8a-02ab3415e2bf\tDuration: 26.73 ms\tBilled Duration: 100 ms \tMemory Size: 128 MB\tMax Memory Used: 75 MB\t\n",
"ingestionTime": 1559763018353
}
],
"nextForwardToken": "f/34783877304859518393868359594929986069206639495374241795",
"nextBackwardToken": "b/34783877303811383369537420289090800615709599058929582080"
}
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
93452e128c6e-0
|
Log groups aren't deleted automatically when you delete a function\. To avoid storing logs indefinitely, delete the log group, or [configure a retention period](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html#SettingLogRetention) after which logs are deleted automatically\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
0bd82a390347-0
|
For more detailed logs, use the [logging library](https://docs.python.org/3/library/logging.html)\.
```
import os
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
logger.info('## ENVIRONMENT VARIABLES')
logger.info(os.environ)
logger.info('## EVENT')
logger.info(event)
```
The output from `logger` includes the log level, timestamp, and request ID\.
```
START RequestId: 1c8df7d3-xmpl-46da-9778-518e6eca8125 Version: $LATEST
[INFO] 2020-01-31T22:12:58.534Z 1c8df7d3-xmpl-46da-9778-518e6eca8125 ## ENVIRONMENT VARIABLES
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
0bd82a390347-1
|
[INFO] 2020-01-31T22:12:58.534Z 1c8df7d3-xmpl-46da-9778-518e6eca8125 environ({'AWS_LAMBDA_LOG_GROUP_NAME': '/aws/lambda/my-function', 'AWS_LAMBDA_LOG_STREAM_NAME': '2020/01/31/[$LATEST]1bbe51xmplb34a2788dbaa7433b0aa4d', 'AWS_LAMBDA_FUNCTION_NAME': 'my-function', ...})
[INFO] 2020-01-31T22:12:58.535Z 1c8df7d3-xmpl-46da-9778-518e6eca8125 ## EVENT
[INFO] 2020-01-31T22:12:58.535Z 1c8df7d3-xmpl-46da-9778-518e6eca8125 {'key': 'value'}
END RequestId: 1c8df7d3-xmpl-46da-9778-518e6eca8125
REPORT RequestId: 1c8df7d3-xmpl-46da-9778-518e6eca8125 Duration: 2.75 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 56 MB Init Duration: 113.51 ms
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
0bd82a390347-2
|
XRAY TraceId: 1-5e34a66a-474xmpl7c2534a87870b4370 SegmentId: 073cxmpl3e442861 Sampled: true
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/python-logging.md
|
54d7c675e797-0
|
AWS Lambda provides an HTTP API for [custom runtimes](runtimes-custom.md) to receive invocation events from Lambda and send response data back within the Lambda [execution environment](lambda-runtimes.md)\.
The OpenAPI specification for the runtime API version **2018\-06\-01** is available here: [runtime\-api\.zip](samples/runtime-api.zip)
Runtimes get an endpoint from the `AWS_LAMBDA_RUNTIME_API` environment variable, add the API version, and use the following resource paths to interact with the API\.
**Example Request**
```
curl "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next"
```
**Topics**
+ [Next invocation](#runtimes-api-next)
+ [Invocation response](#runtimes-api-response)
+ [Invocation error](#runtimes-api-invokeerror)
+ [Initialization error](#runtimes-api-initerror)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-api.md
|
ee9fa8d994b5-0
|
**Path** β `/runtime/invocation/next`
**Method** β **GET**
Retrieves an invocation event\. The response body contains the payload from the invocation, which is a JSON document that contains event data from the function trigger\. The response headers contain additional data about the invocation\.
**Response headers**
+ `Lambda-Runtime-Aws-Request-Id` β The request ID, which identifies the request that triggered the function invocation\.
For example, `8476a536-e9f4-11e8-9739-2dfe598c3fcd`\.
+ `Lambda-Runtime-Deadline-Ms` β The date that the function times out in Unix time milliseconds\.
For example, `1542409706888`\.
+ `Lambda-Runtime-Invoked-Function-Arn` β The ARN of the Lambda function, version, or alias that's specified in the invocation\.
For example, `arn:aws:lambda:us-east-2:123456789012:function:custom-runtime`\.
+ `Lambda-Runtime-Trace-Id` β The [AWS X\-Ray tracing header](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-api.md
|
ee9fa8d994b5-1
|
For example, `Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419;Sampled=1`\.
+ `Lambda-Runtime-Client-Context` β For invocations from the AWS Mobile SDK, data about the client application and device\.
+ `Lambda-Runtime-Cognito-Identity` β For invocations from the AWS Mobile SDK, data about the Amazon Cognito identity provider\.
Call `/runtime/invocation/next` to get the invocation event, and pass it to the function handler for processing\. Do not set a timeout on the `GET` call\. Between when Lambda bootstraps the runtime and when the runtime has an event to return, the runtime process may be frozen for several seconds\.
The request ID tracks the invocation within Lambda\. Use it to specify the invocation when you send the response\.
The tracing header contains the trace ID, parent ID, and sampling decision\. If the request is sampled, the request was sampled by Lambda or an upstream service\. The runtime should set the `_X_AMZN_TRACE_ID` with the value of the header\. The X\-Ray SDK reads this to get the IDs and determine whether to trace the request\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-api.md
|
f6d2975a41cb-0
|
**Path** β `/runtime/invocation/AwsRequestId/response`
**Method** β **POST**
Sends an invocation response to Lambda\. After the runtime invokes the function handler, it posts the response from the function to the invocation response path\. For synchronous invocations, Lambda then sends the response back to the client\.
**Example success request**
```
REQUEST_ID=156cb537-e2d4-11e8-9b34-d36013741fb9
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "SUCCESS"
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-api.md
|
05806fe1d488-0
|
**Path** β `/runtime/invocation/AwsRequestId/error`
**Method** β **POST**
If the function returns an error, the runtime formats the error into a JSON document, and posts it to the invocation error path\.
**Example request body**
```
{
"errorMessage" : "Error parsing event data.",
"errorType" : "InvalidEventDataException"
}
```
**Example error request**
```
REQUEST_ID=156cb537-e2d4-11e8-9b34-d36013741fb9
ERROR="{\"errorMessage\" : \"Error parsing event data.\", \"errorType\" : \"InvalidEventDataException\"}"
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/error" -d "$ERROR" --header "Lambda-Runtime-Function-Error-Type: Unhandled"
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/runtimes-api.md
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.