AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > Persist an item to a DynamoDB table from Lambda Resources: ########################################################################## # Lambda Function # ########################################################################## LambdaPutDynamoDB: Type: AWS::Serverless::Function Properties: CodeUri: src/ Handler: app.handler Runtime: nodejs12.x Timeout: 3 Environment: Variables: DatabaseTable: !Ref DynamoTable Policies: ## Read more about SAM Policy templates at: ## https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html - DynamoDBWritePolicy: TableName: !Ref DynamoTable ########################################################################## # DynamoDB # ########################################################################## DynamoTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: ID AttributeType: S KeySchema: - AttributeName: ID KeyType: HASH BillingMode: PAY_PER_REQUEST ########################################################################## # OUTPUTS # ########################################################################## Outputs: LambdFunction: Value: !Ref LambdaPutDynamoDB Description: LambdaPutDynamoDB function Arn DynamoDbTable: Value: !Ref DynamoTable Description: DynamoDb Table