Amazon SAM template for a DynamoDB application - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon SAM template for a DynamoDB application

You can build this application using Amazon SAM. To learn more about creating Amazon SAM templates, see Amazon SAM template basics in the Amazon Serverless Application Model Developer Guide.

Below is a sample Amazon 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 Amazon Serverless Application Model Developer Guide.