Example on how to configure dynamodb stream in serverless.yml
functions:
dynamodb-trigger:
handler: yourfunction.handler
events:
- stream:
type: dynamodb
batchSize: 1
startingPosition: LATEST
arn:
Fn::GetAtt:
- MyDynamoDbTable
- StreamArn
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:ListStreams
- dynamodb:DescribeTable
- dynamodb:UpdateItem
- dynamodb:GetItem
Resource:
- "Fn::Join": ["", ["arn:aws:dynamodb:" , {"Ref": "AWS::Region"}, ":", {"Ref": "AWS::AccountId"} , ":table/${self:provider.environment.MFA_DYNAMODB_TABLE}"] ]
resources:
Resources:
MyDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.MFA_DYNAMODB_TABLE}
StreamSpecification:
StreamViewType: NEW_IMAGE