AWS SAM template for a DynamoDB application - AWS Lambda

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.