AWS Lambda
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS SAM Template for a DynamoDB Application

You can build this application using AWS SAM. To learn more about creating AWS SAM templates, see AWS SAM Template Basics in the AWS Serverless Application Model Developer Guide.

Below is a sample AWS SAM template for the tutorial application. 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 Properties: Handler: handler Runtime: runtime Policies: AWSLambdaDynamoDBExecutionRole 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 in the AWS Serverless Application Model Developer Guide.