id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
a6dff8498539-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/golang-logging.md
d2737253cdf1-0
Before you use IAM to manage access to Lambda, you should understand what IAM features are available to use with Lambda\. To get a high\-level view of how Lambda and other AWS services work with IAM, see [AWS services that work with IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html) in the *IAM User Guide*\. For an overview of permissions, policies, and roles as they are used by Lambda, see [AWS Lambda permissions](lambda-permissions.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/security_iam_service-with-iam.md
89b5d06a674e-0
Updates an event source mapping\. You can change the function that AWS Lambda invokes, or pause invocation and resume later from the same location\. The following error handling options are only available for stream sources \(DynamoDB and Kinesis\): + `BisectBatchOnFunctionError` \- If the function returns an error, split the batch in two and retry\. + `DestinationConfig` \- Send discarded records to an Amazon SQS queue or Amazon SNS topic\. + `MaximumRecordAgeInSeconds` \- Discard records older than the specified age\. The default value is infinite \(\-1\)\. When set to infinite \(\-1\), failed records are retried until the record expires + `MaximumRetryAttempts` \- Discard records after the specified number of retries\. The default value is infinite \(\-1\)\. When set to infinite \(\-1\), failed records are retried until the record expires\. + `ParallelizationFactor` \- Process multiple batches from each shard concurrently\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
78e5470e0e0a-0
``` PUT /2015-03-31/event-source-mappings/UUID HTTP/1.1 Content-type: application/json { "BatchSize": number, "BisectBatchOnFunctionError": boolean, "DestinationConfig": { "OnFailure": { "Destination": "string" }, "OnSuccess": { "Destination": "string" } }, "Enabled": boolean, "FunctionName": "string", "MaximumBatchingWindowInSeconds": number, "MaximumRecordAgeInSeconds": number, "MaximumRetryAttempts": number, "ParallelizationFactor": number } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
d7f166312be9-0
The request uses the following URI parameters\. ** [UUID](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-UUID"></a> The identifier of the event source mapping\. Required: Yes
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
05f8fe6bfb6d-0
The request accepts the following data in JSON format\. ** [BatchSize](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-BatchSize"></a> The maximum number of items to retrieve in a single batch\. + **Amazon Kinesis** \- Default 100\. Max 10,000\. + **Amazon DynamoDB Streams** \- Default 100\. Max 1,000\. + **Amazon Simple Queue Service** \- Default 10\. Max 10\. + **Amazon Managed Streaming for Apache Kafka** \- Default 100\. Max 10,000\. Type: Integer Valid Range: Minimum value of 1\. Maximum value of 10000\. Required: No ** [BisectBatchOnFunctionError](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-BisectBatchOnFunctionError"></a> \(Streams\) If the function returns an error, split the batch in two and retry\. Type: Boolean Required: No ** [DestinationConfig](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-DestinationConfig"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
05f8fe6bfb6d-1
\(Streams\) An Amazon SQS queue or Amazon SNS topic destination for discarded records\. Type: [DestinationConfig](API_DestinationConfig.md) object Required: No ** [Enabled](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-Enabled"></a> If true, the event source mapping is active\. Set to false to pause polling and invocation\. Type: Boolean Required: No ** [FunctionName](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-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`\. + **Version or Alias ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD`\. + **Partial ARN** \- `123456789012:function:MyFunction`\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
05f8fe6bfb6d-2
+ **Partial ARN** \- `123456789012:function:MyFunction`\. The length constraint applies only to the full ARN\. If you specify only the function name, it's limited to 64 characters in length\. 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: No ** [MaximumBatchingWindowInSeconds](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-MaximumBatchingWindowInSeconds"></a> \(Streams\) The maximum amount of time to gather records before invoking the function, in seconds\. Type: Integer Valid Range: Minimum value of 0\. Maximum value of 300\. Required: No
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
05f8fe6bfb6d-3
Type: Integer Valid Range: Minimum value of 0\. Maximum value of 300\. Required: No ** [MaximumRecordAgeInSeconds](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-MaximumRecordAgeInSeconds"></a> \(Streams\) Discard records older than the specified age\. The default value is infinite \(\-1\)\. Type: Integer Valid Range: Minimum value of 60\. Maximum value of 604800\. Required: No ** [MaximumRetryAttempts](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-MaximumRetryAttempts"></a> \(Streams\) Discard records after the specified number of retries\. The default value is infinite \(\-1\)\. When set to infinite \(\-1\), failed records will be retried until the record expires\. Type: Integer Valid Range: Minimum value of 0\. Maximum value of 10000\. Required: No ** [ParallelizationFactor](#API_UpdateEventSourceMapping_RequestSyntax) ** <a name="SSS-UpdateEventSourceMapping-request-ParallelizationFactor"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
05f8fe6bfb6d-4
\(Streams\) The number of batches to process from each shard concurrently\. Type: Integer Valid Range: Minimum value of 1\. Maximum value of 10\. Required: No
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
fff924ecc99a-0
``` HTTP/1.1 202 Content-type: application/json { "BatchSize": number, "BisectBatchOnFunctionError": boolean, "DestinationConfig": { "OnFailure": { "Destination": "string" }, "OnSuccess": { "Destination": "string" } }, "EventSourceArn": "string", "FunctionArn": "string", "LastModified": number, "LastProcessingResult": "string", "MaximumBatchingWindowInSeconds": number, "MaximumRecordAgeInSeconds": number, "MaximumRetryAttempts": number, "ParallelizationFactor": number, "State": "string", "StateTransitionReason": "string", "Topics": [ "string" ], "UUID": "string" } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-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\. ** [BatchSize](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-BatchSize"></a> The maximum number of items to retrieve in a single batch\. Type: Integer Valid Range: Minimum value of 1\. Maximum value of 10000\. ** [BisectBatchOnFunctionError](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-BisectBatchOnFunctionError"></a> \(Streams\) If the function returns an error, split the batch in two and retry\. The default value is false\. Type: Boolean ** [DestinationConfig](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-DestinationConfig"></a> \(Streams\) An Amazon SQS queue or Amazon SNS topic destination for discarded records\. Type: [DestinationConfig](API_DestinationConfig.md) object
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-1
Type: [DestinationConfig](API_DestinationConfig.md) object ** [EventSourceArn](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-EventSourceArn"></a> The Amazon Resource Name \(ARN\) of the event source\. Type: String Pattern: `arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-])+:([a-z]{2}(-gov)?-[a-z]+-\d{1})?:(\d{12})?:(.*)` ** [FunctionArn](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-FunctionArn"></a> The ARN of the Lambda 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-_]+))?`
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-2
** [LastModified](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-LastModified"></a> The date that the event source mapping was last updated, or its state changed, in Unix time seconds\. Type: Timestamp ** [LastProcessingResult](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-LastProcessingResult"></a> The result of the last AWS Lambda invocation of your Lambda function\. Type: String ** [MaximumBatchingWindowInSeconds](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-MaximumBatchingWindowInSeconds"></a> \(Streams\) The maximum amount of time to gather records before invoking the function, in seconds\. The default value is zero\. Type: Integer Valid Range: Minimum value of 0\. Maximum value of 300\. ** [MaximumRecordAgeInSeconds](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-MaximumRecordAgeInSeconds"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-3
\(Streams\) Discard records older than the specified age\. The default value is infinite \(\-1\)\. When set to infinite \(\-1\), failed records are retried until the record expires\. Type: Integer Valid Range: Minimum value of 60\. Maximum value of 604800\. ** [MaximumRetryAttempts](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-MaximumRetryAttempts"></a> \(Streams\) Discard records after the specified number of retries\. The default value is infinite \(\-1\)\. When set to infinite \(\-1\), failed records are retried until the record expires\. Type: Integer Valid Range: Minimum value of 0\. Maximum value of 10000\. ** [ParallelizationFactor](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-ParallelizationFactor"></a> \(Streams\) The number of batches to process from each shard concurrently\. The default value is 1\. Type: Integer Valid Range: Minimum value of 1\. Maximum value of 10\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-4
Type: Integer Valid Range: Minimum value of 1\. Maximum value of 10\. ** [State](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-State"></a> The state of the event source mapping\. It can be one of the following: `Creating`, `Enabling`, `Enabled`, `Disabling`, `Disabled`, `Updating`, or `Deleting`\. Type: String ** [StateTransitionReason](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-StateTransitionReason"></a> Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service\. Type: String ** [Topics](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-Topics"></a> \(MSK\) The name of the Kafka topic\. Type: Array of strings Array Members: Fixed number of 1 item\. Length Constraints: Minimum length of 1\. Maximum length of 249\. Pattern: `^[^.]([a-zA-Z0-9\-_.]+)`
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
5044fa8b9a6c-5
Pattern: `^[^.]([a-zA-Z0-9\-_.]+)` ** [UUID](#API_UpdateEventSourceMapping_ResponseSyntax) ** <a name="SSS-UpdateEventSourceMapping-response-UUID"></a> The identifier of the event source mapping\. Type: String
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
b0dd4b05bda2-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 **ResourceInUseException** The operation conflicts with the resource's availability\. For example, you attempted to update an EventSource Mapping in CREATING, or tried to delete a EventSource mapping currently in the UPDATING state\. 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_UpdateEventSourceMapping.md
aa1941108992-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/UpdateEventSourceMapping) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/UpdateEventSourceMapping)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
aa1941108992-1
+ [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/UpdateEventSourceMapping) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/UpdateEventSourceMapping)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateEventSourceMapping.md
ecb47e157cc5-0
When building applications on AWS Lambda the core components are Lambda functions and triggers\. A trigger is the AWS service or application that invokes a function, and a Lambda function is the code and runtime that process events\. To illustrate, consider the following scenarios: + **File processing** – Suppose you have a photo sharing application\. People use your application to upload photos, and the application stores these user photos in an Amazon S3 bucket\. Then, your application creates a thumbnail version of each user's photos and displays them on the user's profile page\. In this scenario, you may choose to create a Lambda function that creates a thumbnail automatically\. Amazon S3 is one of the supported AWS event sources that can publish *object\-created events* and invoke your Lambda function\. Your Lambda function code can read the photo object from the S3 bucket, create a thumbnail version, and then save it in another S3 bucket\. + **Data and analytics** – Suppose you are building an analytics application and storing raw data in a DynamoDB table\. When you write, update, or delete items in a table, DynamoDB streams can publish item update events to a stream associated with the table\. In this case, the event data provides the item key, event name \(such as insert, update, and delete\), and other relevant details\. You can write a Lambda function to generate custom metrics by aggregating raw data\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-usecases.md
ecb47e157cc5-1
+ **Websites** – Suppose you are creating a website and you want to host the backend logic on Lambda\. You can invoke your Lambda function over HTTP using Amazon API Gateway as the HTTP endpoint\. Now, your web client can invoke the API, and then API Gateway can route the request to Lambda\. + **Mobile applications** – Suppose you have a custom mobile application that produces events\. You can create a Lambda function to process events published by your custom application\. For example, in this scenario you can configure a Lambda function to process the clicks within your custom mobile application\. AWS Lambda supports many AWS services as event sources\. For more information, see [Using AWS Lambda with other services](lambda-services.md)\. When you configure these event sources to trigger a Lambda function, the Lambda function is invoked automatically when events occur\. You define *event source mapping*, which is how you identify what events to track and which Lambda function to invoke\. The following are introductory examples of event sources and how the end\-to\-end experience works\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-usecases.md
77c16eb1aa50-0
Amazon S3 can publish events of different types, such as PUT, POST, COPY, and DELETE object events on a bucket\. Using the bucket notification feature, you can configure an event source mapping that directs Amazon S3 to invoke a Lambda function when a specific type of event occurs, as shown in the following illustration\. ![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/push-s3-example-10.png) The diagram illustrates the following sequence: 1. The user creates an object in a bucket\. 1. Amazon S3 detects the object created event\. 1. Amazon S3 invokes your Lambda function using the permissions provided by the [execution role](lambda-intro-execution-role.md)\. 1. AWS Lambda executes the Lambda function, specifying the event as a parameter\. You configure Amazon S3 to invoke your function as a bucket notification action\. To grant Amazon S3 permission to invoke the function, update the function's [resource\-based policy](access-control-resource-based.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-usecases.md
676d8faf77b3-0
For poll\-based event sources, AWS Lambda polls the source and then invokes the Lambda function when records are detected on that source\. + [CreateEventSourceMapping](API_CreateEventSourceMapping.md) + [UpdateEventSourceMapping](API_UpdateEventSourceMapping.md) The following diagram shows how a custom application writes records to a Kinesis stream\. ![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/kinesis-pull-10.png) The diagram illustrates the following sequence: 1. The custom application writes records to a Kinesis stream\. 1. AWS Lambda continuously polls the stream, and invokes the Lambda function when the service detects new records on the stream\. AWS Lambda knows which stream to poll and which Lambda function to invoke based on the event source mapping you create in Lambda\. 1. The Lambda function is invoked with the incoming event\. When working with stream\-based event sources, you create event source mappings in AWS Lambda\. Lambda reads items from the stream invokes the function synchronously\. You don't need to grant Lambda permission to invoke the function, but it does need permission to read from the stream\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/applications-usecases.md
15ec67f8de91-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 Lambda application from the [tutorial](with-kinesis-example.md)\. The function and handler in the template are for the Node\.js code\. If you use a different code sample, update the values accordingly\. **Example template\.yaml \- Kinesis stream** ``` AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: LambdaFunction: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: Handler: index.handler Runtime: nodejs12.x Timeout: 10 Tracing: Active Events: Stream: Type: Kinesis Properties: Stream: !GetAtt stream.Arn BatchSize: 100
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example-use-app-spec.md
15ec67f8de91-1
Stream: Type: Kinesis Properties: Stream: !GetAtt stream.Arn BatchSize: 100 StartingPosition: LATEST stream: Type: AWS::Kinesis::Stream Properties: ShardCount: 1 Outputs: FunctionName: Description: "Function name" Value: !Ref LambdaFunction StreamARN: Description: "Stream ARN" Value: !GetAtt stream.Arn ``` The template creates a Lambda function, a Kinesis stream, and an event source mapping\. The event source mapping reads from the stream and invokes the function\. To use an [HTTP/2 stream consumer](with-kinesis.md#services-kinesis-configure), create the consumer in the template and configure the event source mapping to read from the consumer instead of from the stream\. **Example template\.yaml \- Kinesis stream consumer** ``` AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: A function that processes data from a Kinesis stream. Resources: function:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example-use-app-spec.md
15ec67f8de91-2
Description: A function that processes data from a Kinesis stream. Resources: function: Type: [AWS::Serverless::Function](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) Properties: Handler: index.handler Runtime: nodejs12.x Timeout: 10 Tracing: Active Events: Stream: Type: Kinesis Properties: Stream: !GetAtt streamConsumer.ConsumerARN StartingPosition: LATEST BatchSize: 100 stream: Type: "AWS::Kinesis::Stream" Properties: ShardCount: 1 streamConsumer: Type: "AWS::Kinesis::StreamConsumer" Properties: StreamARN: !GetAtt stream.Arn ConsumerName: "TestConsumer" Outputs: FunctionName: Description: "Function name" Value: !Ref function StreamARN: Description: "Stream ARN" Value: !GetAtt stream.Arn ConsumerARN: Description: "Stream consumer ARN" Value: !GetAtt streamConsumer.ConsumerARN ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example-use-app-spec.md
15ec67f8de91-3
Description: "Stream consumer ARN" Value: !GetAtt streamConsumer.ConsumerARN ``` 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/with-kinesis-example-use-app-spec.md
2848e9fe7a40-0
Updates the configuration of 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_UpdateAlias.md
095d93a628cb-0
``` PUT /2015-03-31/functions/FunctionName/aliases/Name HTTP/1.1 Content-type: application/json { "Description": "string", "FunctionVersion": "string", "RevisionId": "string", "RoutingConfig": { "AdditionalVersionWeights": { "string" : number } } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
54736b982c69-0
The request uses the following URI parameters\. ** [FunctionName](#API_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-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_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-request-Name"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
54736b982c69-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_UpdateAlias.md
b6ddf5772810-0
The request accepts the following data in JSON format\. ** [Description](#API_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-request-Description"></a> A description of the alias\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\. Required: No ** [FunctionVersion](#API_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-request-FunctionVersion"></a> The function version that the alias invokes\. Type: String Length Constraints: Minimum length of 1\. Maximum length of 1024\. Pattern: `(\$LATEST|[0-9]+)` Required: No ** [RevisionId](#API_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-request-RevisionId"></a> Only update the alias if the revision ID matches the ID that's specified\. Use this option to avoid modifying an alias that has changed since you last read it\. Type: String Required: No ** [RoutingConfig](#API_UpdateAlias_RequestSyntax) ** <a name="SSS-UpdateAlias-request-RoutingConfig"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
b6ddf5772810-1
The [routing configuration](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html#configuring-alias-routing) of the alias\. Type: [AliasRoutingConfiguration](API_AliasRoutingConfiguration.md) object Required: No
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
3d82f6cf4641-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_UpdateAlias.md
8219342d1ce1-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_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-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_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-response-Description"></a> A description of the alias\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\. ** [FunctionVersion](#API_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-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_UpdateAlias.md
8219342d1ce1-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_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-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_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-response-RevisionId"></a> A unique identifier that changes when you update the alias\. Type: String ** [RoutingConfig](#API_UpdateAlias_ResponseSyntax) ** <a name="SSS-UpdateAlias-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_UpdateAlias.md
1b2ef91802b6-0
**InvalidParameterValueException** One of the parameters in the request is invalid\. HTTP Status Code: 400 **PreconditionFailedException** The RevisionId provided does not match the latest RevisionId for the Lambda function or alias\. Call the `GetFunction` or the `GetAlias` API to retrieve the latest RevisionId for your resource\. HTTP Status Code: 412 **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_UpdateAlias.md
6f341d6b9768-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/UpdateAlias) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/UpdateAlias) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/UpdateAlias) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/UpdateAlias) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/UpdateAlias) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/UpdateAlias) + [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/UpdateAlias)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
6f341d6b9768-1
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/UpdateAlias) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/UpdateAlias)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_UpdateAlias.md
ff70b81035d3-0
Returns information about a version of an [AWS Lambda layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html), with a link to download the layer archive that's valid for 10 minutes\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
803036617a8c-0
``` GET /2018-10-31/layers/LayerName/versions/VersionNumber HTTP/1.1 ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
2d79c305a183-0
The request uses the following URI parameters\. ** [LayerName](#API_GetLayerVersion_RequestSyntax) ** <a name="SSS-GetLayerVersion-request-LayerName"></a> The name or Amazon Resource Name \(ARN\) of the layer\. 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-_]+)|[a-zA-Z0-9-_]+` Required: Yes ** [VersionNumber](#API_GetLayerVersion_RequestSyntax) ** <a name="SSS-GetLayerVersion-request-VersionNumber"></a> The version number\. Required: Yes
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
c0877c594252-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_GetLayerVersion.md
fb61c11f84d1-0
``` HTTP/1.1 200 Content-type: application/json { "CompatibleRuntimes": [ "string" ], "Content": { "CodeSha256": "string", "CodeSize": number, "Location": "string" }, "CreatedDate": "string", "Description": "string", "LayerArn": "string", "LayerVersionArn": "string", "LicenseInfo": "string", "Version": number } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
fb7a8b03faa1-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\. ** [CompatibleRuntimes](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-CompatibleRuntimes"></a> The layer's compatible runtimes\. Type: Array of strings Array Members: Maximum number of 5 items\. 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` ** [Content](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-Content"></a> Details about the layer version\. Type: [LayerVersionContentOutput](API_LayerVersionContentOutput.md) object ** [CreatedDate](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-CreatedDate"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
fb7a8b03faa1-1
The date that the layer version was created, in [ISO\-8601 format](https://www.w3.org/TR/NOTE-datetime) \(YYYY\-MM\-DDThh:mm:ss\.sTZD\)\. Type: String ** [Description](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-Description"></a> The description of the version\. Type: String Length Constraints: Minimum length of 0\. Maximum length of 256\. ** [LayerArn](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-LayerArn"></a> The ARN of the layer\. Type: String 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-_]+` ** [LayerVersionArn](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-LayerVersionArn"></a> The ARN of the layer version\. 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_GetLayerVersion.md
fb7a8b03faa1-2
The ARN of the layer version\. Type: String 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]+` ** [LicenseInfo](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-LicenseInfo"></a> The layer's software license\. Type: String Length Constraints: Maximum length of 512\. ** [Version](#API_GetLayerVersion_ResponseSyntax) ** <a name="SSS-GetLayerVersion-response-Version"></a> The version number\. Type: Long
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
50bbd6f2ee8b-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_GetLayerVersion.md
1816c93f4ed6-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/GetLayerVersion) + [AWS SDK for \.NET](https://docs.aws.amazon.com/goto/DotNetSDKV3/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for Go](https://docs.aws.amazon.com/goto/SdkForGoV1/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for Java](https://docs.aws.amazon.com/goto/SdkForJava/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for JavaScript](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/lambda-2015-03-31/GetLayerVersion)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
1816c93f4ed6-1
+ [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/lambda-2015-03-31/GetLayerVersion) + [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/lambda-2015-03-31/GetLayerVersion)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_GetLayerVersion.md
c3ad31d5b2e3-0
In this tutorial, you create a Lambda function to consume events from a Kinesis stream\. The following diagram illustrates the application flow: ![\[Image NOT FOUND\]](http://docs.aws.amazon.com/lambda/latest/dg/images/kinesis-pull-10.png) 1. Custom app writes records to the stream\. 1. AWS Lambda polls the stream and, when it detects new records in the stream, invokes your Lambda function\. 1. AWS Lambda executes the Lambda function by assuming the execution role you specified at the time you created the Lambda function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
eddbe52b1f35-0
This tutorial assumes that you have some knowledge of basic Lambda operations and the Lambda console\. If you haven't already, follow the instructions in [Getting started with AWS Lambda](getting-started.md) to create your first Lambda function\. To follow the procedures in this guide, you will need a command line terminal or shell to run commands\. Commands are shown in listings preceded by a prompt symbol \($\) and the name of the current directory, when appropriate: ``` ~/lambda-project$ this is a command this is output ``` For long commands, an escape character \(`\`\) is used to split a command over multiple lines\. On Linux and macOS, use your preferred shell and package manager\. On Windows 10, you can [install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows\-integrated version of Ubuntu and Bash\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
38ed74b6fbd1-0
Create the [execution role](lambda-intro-execution-role.md) that gives your function permission to access AWS resources\. **To create an execution role** 1. Open the [roles page](https://console.aws.amazon.com/iam/home#/roles) in the IAM console\. 1. Choose **Create role**\. 1. Create a role with the following properties\. + **Trusted entity** – **AWS Lambda**\. + **Permissions** – **AWSLambdaKinesisExecutionRole**\. + **Role name** – **lambda\-kinesis\-role**\. The **AWSLambdaKinesisExecutionRole** policy has the permissions that the function needs to read items from Kinesis and write logs to CloudWatch Logs\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
9c5eb4d57e5f-0
The following example code receives a Kinesis event input and processes the messages that it contains\. For illustration, the code writes some of the incoming event data to CloudWatch Logs\. **Note** For sample code in other languages, see [Sample function code](with-kinesis-create-package.md)\. **Example index\.js** ``` console.log('Loading function'); exports.handler = function(event, context) { //console.log(JSON.stringify(event, null, 2)); event.Records.forEach(function(record) { // Kinesis data is base64 encoded so decode here var payload = Buffer.from(record.kinesis.data, 'base64').toString('ascii'); console.log('Decoded payload:', payload); }); }; ``` **To create the function** 1. Copy the sample code into a file named `index.js`\. 1. Create a deployment package\. ``` $ zip function.zip index.js ``` 1. Create a Lambda function with the `create-function` command\. ``` $ aws lambda create-function --function-name ProcessKinesisRecords \
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
9c5eb4d57e5f-1
``` $ aws lambda create-function --function-name ProcessKinesisRecords \ --zip-file fileb://function.zip --handler index.handler --runtime nodejs12.x \ --role arn:aws:iam::123456789012:role/lambda-kinesis-role ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
33a6a761034b-0
Invoke your Lambda function manually using the `invoke` AWS Lambda CLI command and a sample Kinesis event\. **To test the Lambda function** 1. Copy the following JSON into a file and save it as `input.txt`\. ``` { "Records": [ { "kinesis": { "kinesisSchemaVersion": "1.0", "partitionKey": "1", "sequenceNumber": "49590338271490256608559692538361571095921575989136588898", "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==", "approximateArrivalTimestamp": 1545084650.987 }, "eventSource": "aws:kinesis", "eventVersion": "1.0", "eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898", "eventName": "aws:kinesis:record", "invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-kinesis-role",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
33a6a761034b-1
"awsRegion": "us-east-2", "eventSourceARN": "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream" } ] } ``` 1. Use the `invoke` command to send the event to the function\. ``` $ aws lambda invoke --function-name ProcessKinesisRecords --payload file://input.txt out.txt ``` The response is saved to `out.txt`\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
896cec50cf0e-0
Use the `create-stream ` command to create a stream\. ``` $ aws kinesis create-stream --stream-name lambda-stream --shard-count 1 ``` Run the following `describe-stream` command to get the stream ARN\. ``` $ aws kinesis describe-stream --stream-name lambda-stream { "StreamDescription": { "Shards": [ { "ShardId": "shardId-000000000000", "HashKeyRange": { "StartingHashKey": "0", "EndingHashKey": "340282366920746074317682119384634633455" }, "SequenceNumberRange": { "StartingSequenceNumber": "49591073947768692513481539594623130411957558361251844610" } } ], "StreamARN": "arn:aws:kinesis:us-west-2:123456789012:stream/lambda-stream", "StreamName": "lambda-stream", "StreamStatus": "ACTIVE", "RetentionPeriodHours": 24, "EnhancedMonitoring": [
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
896cec50cf0e-1
"StreamStatus": "ACTIVE", "RetentionPeriodHours": 24, "EnhancedMonitoring": [ { "ShardLevelMetrics": [] } ], "EncryptionType": "NONE", "KeyId": null, "StreamCreationTimestamp": 1544828156.0 } } ``` You use the stream ARN in the next step to associate the stream with your Lambda function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
2a7319f367ca-0
Run the following AWS CLI `add-event-source` command\. ``` $ aws lambda create-event-source-mapping --function-name ProcessKinesisRecords \ --event-source arn:aws:kinesis:us-west-2:123456789012:stream/lambda-stream \ --batch-size 100 --starting-position LATEST ``` Note the mapping ID for later use\. You can get a list of event source mappings by running the `list-event-source-mappings` command\. ``` $ aws lambda list-event-source-mappings --function-name ProcessKinesisRecords \ --event-source arn:aws:kinesis:us-west-2:123456789012:stream/lambda-stream ``` In the response, you can verify the status value is `enabled`\. Event source mappings can be disabled to pause polling temporarily without losing any records\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
725fa77527af-0
To test the event source mapping, add event records to your Kinesis stream\. The `--data` value is a string that the CLI encodes to base64 prior to sending it to Kinesis\. You can run the same command more than once to add multiple records to the stream\. ``` $ aws kinesis put-record --stream-name lambda-stream --partition-key 1 \ --data "Hello, this is a test." ``` Lambda uses the execution role to read records from the stream\. Then it invokes your Lambda function, passing in batches of records\. The function decodes data from each record and logs it, sending the output to CloudWatch Logs\. View the logs in the [CloudWatch console](https://console.aws.amazon.com/cloudwatch)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-kinesis-example.md
aedb20766b4b-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 `puts` statements, 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\.rb** ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
f3ef38d5f6c5-0
def handler(event:, context:) puts "## ENVIRONMENT VARIABLES" puts ENV.to_a puts "## EVENT" puts event.to_a end ``` For more detailed logs, use the [logger library](https://ruby-doc.org/stdlib-2.7.0/libdoc/logger/rdoc/index.html)\. ``` require 'logger' def handler(event:, context:) logger = Logger.new($stdout) logger.info('## ENVIRONMENT VARIABLES') logger.info(ENV.to_a) logger.info('## EVENT') logger.info(event) event.to_a end ``` The output from `logger` includes the timestamp, process ID, log level, and request ID\. ``` I, [2019-10-26T10:04:01.689856 #8] INFO 6573a3a0-2fb1-4e78-a582-2c769282e0bd -- : ## EVENT
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
f3ef38d5f6c5-1
I, [2019-10-26T10:04:01.689874 #8] INFO 6573a3a0-2fb1-4e78-a582-2c769282e0bd -- : {"key1"=>"value1", "key2"=>"value2", "key3"=>"value3"} ``` 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/ruby-logging.md
f3ef38d5f6c5-2
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/ruby-logging.md
f3ef38d5f6c5-3
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`\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
f3ef38d5f6c5-4
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\. **Example log format** ``` START RequestId: 50aba555-99c8-4b21-8358-644ee996a05f Version: $LATEST
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
b0e1f06ee5cb-0
AWS_LAMBDA_FUNCTION_VERSION $LATEST AWS_LAMBDA_LOG_GROUP_NAME /aws/lambda/my-function AWS_LAMBDA_LOG_STREAM_NAME 2020/01/31/[$LATEST]3f34xmpl069f4018b4a773bcfe8ed3f9 AWS_EXECUTION_ENV AWS_Lambda_ruby2.5 ...
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
195c391a69ee-0
key value END RequestId: 50aba555-xmpl-4b21-8358-644ee996a05f REPORT RequestId: 50aba555-xmpl-4b21-8358-644ee996a05f Duration: 12.96 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 48 MB Init Duration: 117.86 ms XRAY TraceId: 1-5e34a246-2a04xmpl0fa44eb60ea08c5f SegmentId: 454xmpl46ca1c7d3 Sampled: true ``` The Ruby 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/ruby-logging.md
195c391a69ee-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)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/ruby-logging.md
7ba458752605-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/ruby-logging.md
dffd151df7a0-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/ruby-logging.md
dffd151df7a0-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/ruby-logging.md
dffd151df7a0-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/ruby-logging.md
dffd151df7a0-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/ruby-logging.md
dffd151df7a0-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/ruby-logging.md
7c3df4268ef1-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/ruby-logging.md
192505d2d6c9-0
To access [environment variables](configuration-envvars.md) in Go, use the [Getenv](https://golang.org/pkg/os/#Getenv) function\. The following explains how to do this\. Note that the function imports the [fmt](https://golang.org/pkg/fmt/) package to format the printed results and the [os](https://golang.org/pkg/os/) package, a platform\-independent system interface that allows you to access environment variables\. ``` package main import ( "fmt" "os" "github.com/aws/aws-lambda-go/lambda" ) func main() { fmt.Printf("%s is %s. years old\n", os.Getenv("NAME"), os.Getenv("AGE")) } ``` For a list of environment variables that are set by the Lambda runtime, see [Runtime environment variables](configuration-envvars.md#configuration-envvars-runtime)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-envvars.md
c376eaf2f08c-0
You can use AWS Identity and Access Management \(IAM\) to manage access to the Lambda API and resources like functions and layers\. For users and applications in your account that use Lambda, you manage permissions in a permissions policy that you can apply to IAM users, groups, or roles\. To grant permissions to other accounts or AWS services that use your Lambda resources, you use a policy that applies to the resource itself\. A Lambda function also has a policy, called an [execution role](lambda-intro-execution-role.md), that grants it permission to access AWS services and resources\. At a minimum, your function needs access to Amazon CloudWatch Logs for log streaming\. If you [use AWS X\-Ray to trace your function](services-xray.md), or your function accesses services with the AWS SDK, you grant it permission to call them in the execution role\. Lambda also uses the execution role to get permission to read from event sources when you use an [event source mapping](invocation-eventsourcemapping.md) to trigger your function\. **Note** If your function needs network access to a resource like a relational database that isn't accessible through AWS APIs or the internet, [configure it to connect to your VPC](configuration-vpc.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-permissions.md
c376eaf2f08c-1
Use [resource\-based policies](access-control-resource-based.md) to give other accounts and AWS services permission to use your Lambda resources\. Lambda resources include functions, versions, aliases, and layer versions\. Each of these resources has a permissions policy that applies when the resource is accessed, in addition to any policies that apply to the user\. When an AWS service like Amazon S3 calls your Lambda function, the resource\-based policy gives it access\. To manage permissions for users and applications in your accounts, [use the managed policies that Lambda provides](access-control-identity-based.md), or write your own\. The Lambda console uses multiple services to get information about your function's configuration and triggers\. You can use the managed policies as\-is, or as a starting point for more restrictive policies\. You can restrict user permissions by the resource an action affects and, in some cases, by additional conditions\. For example, you can specify a pattern for the Amazon Resource Name \(ARN\) of a function that requires a user to include their user name in the name of functions that they create\. Additionally, you can add a condition that requires that the user configure functions to use a specific layer to, for example, pull in logging software\. For the resources and conditions that are supported by each action, see [Resources and Conditions](lambda-api-permissions-ref.md)\. For more information about IAM, see [What is IAM?](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) in the *IAM User Guide*\. **Topics**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/lambda-permissions.md
c376eaf2f08c-2
**Topics** + [AWS Lambda execution role](lambda-intro-execution-role.md) + [Using resource\-based policies for AWS Lambda](access-control-resource-based.md) + [Identity\-based IAM policies for AWS Lambda](access-control-identity-based.md) + [Resources and conditions for Lambda actions](lambda-api-permissions-ref.md) + [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/lambda-permissions.md
0d4e09d75bb2-0
When Lambda runs your function, it passes a context object to the [handler](golang-handler.md)\. This object provides methods and properties with information about the invocation, function, and execution environment\. The Lambda context library provides the following global variables, methods, and properties\. **Global variables** + `FunctionName` – The name of the Lambda function\. + `FunctionVersion` – The [version](configuration-versions.md) of the function\. + `MemoryLimitInMB` – The amount of memory that's allocated for the function\. + `LogGroupName` – The log group for the function\. + `LogStreamName` – The log stream for the function instance\. **Context methods** + `Deadline` – Returns the date that the execution times out, in Unix time milliseconds\. **Context properties** + `InvokedFunctionArn` – The Amazon Resource Name \(ARN\) that's used to invoke the function\. Indicates if the invoker specified a version number or alias\. + `AwsRequestID` – The identifier of the invocation request\. + `Identity` – \(mobile apps\) Information about the Amazon Cognito identity that authorized the request\. + `ClientContext` – \(mobile apps\) Client context that's provided to Lambda by the client application\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-context.md
dc4ae4d6f205-0
Lambda functions have access to metadata about their environment and the invocation request\. This can be accessed at [Package context](https://golang.org/pkg/context/)\. Should your handler include `context.Context` as a parameter, Lambda will insert information about your function into the context's `Value` property\. Note that you need to import the `lambdacontext` library to access the contents of the `context.Context` object\. ``` package main import ( "context" "log" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-lambda-go/lambdacontext" ) func CognitoHandler(ctx context.Context) { lc, _ := lambdacontext.FromContext(ctx) log.Print(lc.Identity.CognitoIdentityPoolID) } func main() { lambda.Start(CognitoHandler) } ``` In the example above, `lc` is the variable used to consume the information that the context object captured and `log.Print(lc.Identity.CognitoIdentityPoolID)` prints that information, in this case, the CognitoIdentityPoolID\. The following example introduces how to use the context object to monitor how long it takes to execute your Lambda function\. This allows you to analyze performance expectations and adjust your function code accordingly, if needed\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-context.md
dc4ae4d6f205-1
``` package main import ( "context" "log" "time" "github.com/aws/aws-lambda-go/lambda" ) func LongRunningHandler(ctx context.Context) (string, error) { deadline, _ := ctx.Deadline() deadline = deadline.Add(-100 * time.Millisecond) timeoutChannel := time.After(time.Until(deadline)) for { select { case <- timeoutChannel: return "Finished before timing out.", nil default: log.Print("hello!") time.Sleep(50 * time.Millisecond) } } } func main() { lambda.Start(LongRunningHandler) } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/golang-context.md
f764600de315-0
Sample code is available for the following languages\. **Topics** + [Node\.js](#with-cloudtrail-example-deployment-pkg-nodejs)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-cloudtrail-create-package.md
376a5081d976-0
The following example processes CloudTrail logs, and sends a notification when an Amazon SNS topic was created\. **Example index\.js** ``` var aws = require('aws-sdk'); var zlib = require('zlib'); var async = require('async'); var EVENT_SOURCE_TO_TRACK = /sns.amazonaws.com/; var EVENT_NAME_TO_TRACK = /CreateTopic/; var DEFAULT_SNS_REGION = 'us-west-2'; var SNS_TOPIC_ARN = 'The ARN of your SNS topic'; var s3 = new aws.S3(); var sns = new aws.SNS({ apiVersion: '2010-03-31', region: DEFAULT_SNS_REGION }); exports.handler = function(event, context, callback) { var srcBucket = event.Records[0].s3.bucket.name; var srcKey = event.Records[0].s3.object.key; async.waterfall([ function fetchLogFromS3(next){ console.log('Fetching compressed log from S3...'); s3.getObject({ Bucket: srcBucket, Key: srcKey
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-cloudtrail-create-package.md
376a5081d976-1
s3.getObject({ Bucket: srcBucket, Key: srcKey }, next); }, function uncompressLog(response, next){ console.log("Uncompressing log..."); zlib.gunzip(response.Body, next); }, function publishNotifications(jsonBuffer, next) { console.log('Filtering log...'); var json = jsonBuffer.toString(); console.log('CloudTrail JSON from S3:', json); var records; try { records = JSON.parse(json); } catch (err) { next('Unable to parse CloudTrail JSON: ' + err); return; } var matchingRecords = records .Records .filter(function(record) { return record.eventSource.match(EVENT_SOURCE_TO_TRACK) && record.eventName.match(EVENT_NAME_TO_TRACK); }); console.log('Publishing ' + matchingRecords.length + ' notification(s) in parallel...'); async.each( matchingRecords,
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-cloudtrail-create-package.md
376a5081d976-2
async.each( matchingRecords, function(record, publishComplete) { console.log('Publishing notification: ', record); sns.publish({ Message: 'Alert... SNS topic created: \n TopicARN=' + record.responseElements.topicArn + '\n\n' + JSON.stringify(record), TopicArn: SNS_TOPIC_ARN }, publishComplete); }, next ); } ], function (err) { if (err) { console.error('Failed to publish notifications: ', err); } else { console.log('Successfully published all notifications.'); } callback(null,"message"); }); }; ``` Zip up the sample code to create a deployment package\. For instructions, see [AWS Lambda deployment package in Node\.js](nodejs-package.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/with-cloudtrail-create-package.md
6dc823322d45-0
Invokes a Lambda function\. You can invoke a function synchronously \(and wait for the response\), or asynchronously\. To invoke a function asynchronously, set `InvocationType` to `Event`\. For [synchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-sync.html), details about the function response, including errors, are included in the response body and headers\. For either invocation type, you can find more information in the [execution log](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions.html) and [trace](https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html)\. When an error occurs, your function may be invoked multiple times\. Retry behavior varies by error type, client, event source, and invocation type\. For example, if you invoke a function asynchronously and it returns an error, Lambda executes the function up to two more times\. For more information, see [Retry Behavior](https://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
6dc823322d45-1
For [asynchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html), Lambda adds events to a queue before sending them to your function\. If your function does not have enough capacity to keep up with the queue, events may be lost\. Occasionally, your function may receive the same event multiple times, even if no error occurs\. To retain events that were not processed, configure your function with a [dead\-letter queue](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#dlq)\. The status code in the API response doesn't reflect function errors\. Error codes are reserved for errors that prevent your function from executing, such as permissions errors, [limit errors](https://docs.aws.amazon.com/lambda/latest/dg/limits.html), or issues with your function's code and configuration\. For example, Lambda returns `TooManyRequestsException` if executing the function would cause you to exceed a concurrency limit at either the account level \(`ConcurrentInvocationLimitExceeded`\) or function level \(`ReservedFunctionConcurrentInvocationLimitExceeded`\)\. For functions with a long timeout, your client might be disconnected during synchronous invocation while it waits for a response\. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with timeout or keep\-alive settings\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
6dc823322d45-2
This operation requires permission for the [lambda:InvokeFunction](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awslambda.html) action\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
d8edc96a1232-0
``` POST /2015-03-31/functions/FunctionName/invocations?Qualifier=Qualifier HTTP/1.1 X-Amz-Invocation-Type: InvocationType X-Amz-Log-Type: LogType X-Amz-Client-Context: ClientContext Payload ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
70690a59ac4e-0
The request uses the following URI parameters\. ** [ClientContext](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-ClientContext"></a> Up to 3583 bytes of base64\-encoded data about the invoking client to pass to the function in the context object\. ** [FunctionName](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-FunctionName"></a> The name of the Lambda function, version, or alias\. **Name formats** + **Function name** \- `my-function` \(name\-only\), `my-function:v1` \(with alias\)\. + **Function ARN** \- `arn:aws:lambda:us-west-2:123456789012:function:my-function`\. + **Partial ARN** \- `123456789012:function:my-function`\. You can append a version number or alias to any of the formats\. The length constraint applies only to the full ARN\. If you specify only the function name, it is limited to 64 characters in length\. Length Constraints: Minimum length of 1\. Maximum length of 170\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
70690a59ac4e-1
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 ** [InvocationType](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-InvocationType"></a> Choose from the following options\. + `RequestResponse` \(default\) \- Invoke the function synchronously\. Keep the connection open until the function returns a response or times out\. The API response includes the function response and additional data\. + `Event` \- Invoke the function asynchronously\. Send events that fail multiple times to the function's dead\-letter queue \(if it's configured\)\. The API response only includes a status code\. + `DryRun` \- Validate parameter values and verify that the user or role has permission to invoke the function\. Valid Values:` Event | RequestResponse | DryRun`
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
70690a59ac4e-2
Valid Values:` Event | RequestResponse | DryRun` ** [LogType](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-LogType"></a> Set to `Tail` to include the execution log in the response\. Valid Values:` None | Tail` ** [Qualifier](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-Qualifier"></a> Specify a version or alias to invoke a published version of the function\. Length Constraints: Minimum length of 1\. Maximum length of 128\. Pattern: `(|[a-zA-Z0-9$_-]+)`
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
d4669786118a-0
The request accepts the following binary data\. ** [Payload](#API_Invoke_RequestSyntax) ** <a name="SSS-Invoke-request-Payload"></a> The JSON that you want to provide to your Lambda function as input\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
f193c3596327-0
``` HTTP/1.1 StatusCode X-Amz-Function-Error: FunctionError X-Amz-Log-Result: LogResult X-Amz-Executed-Version: ExecutedVersion Payload ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
4b7f2a1b00be-0
If the action is successful, the service sends back the following HTTP response\. ** [StatusCode](#API_Invoke_ResponseSyntax) ** <a name="SSS-Invoke-response-StatusCode"></a> The HTTP status code is in the 200 range for a successful request\. For the `RequestResponse` invocation type, this status code is 200\. For the `Event` invocation type, this status code is 202\. For the `DryRun` invocation type, the status code is 204\. The response returns the following HTTP headers\. ** [ExecutedVersion](#API_Invoke_ResponseSyntax) ** <a name="SSS-Invoke-response-ExecutedVersion"></a> The version of the function that executed\. When you invoke a function with an alias, this indicates which version the alias resolved to\. Length Constraints: Minimum length of 1\. Maximum length of 1024\. Pattern: `(\$LATEST|[0-9]+)` ** [FunctionError](#API_Invoke_ResponseSyntax) ** <a name="SSS-Invoke-response-FunctionError"></a> If present, indicates that an error occurred during function execution\. Details about the error are included in the response payload\. ** [LogResult](#API_Invoke_ResponseSyntax) ** <a name="SSS-Invoke-response-LogResult"></a>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md
4b7f2a1b00be-1
The last 4 KB of the execution log, which is base64 encoded\. The response returns the following as the HTTP body\. ** [Payload](#API_Invoke_ResponseSyntax) ** <a name="SSS-Invoke-response-Payload"></a> The response from the function, or an error object\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-lambda-developer-guide/doc_source/API_Invoke.md