I have searched high and low and can not for the life of me get serverless to setup a dynamodb trigger.
I have used:
- stream:
type: dynamodb
batchSize: 100
enabled: true
arn:
Fn::GetAtt:
- MyDynamoDbTable
- StreamArn
I tried a hard coded arn and nothing has occurred that I can see in the aws console. I am new to serverless. If you have any pointers please post.
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
events:
- stream: arn:aws:dynamodb:us-west-2:xxxxxx:table/tableName/stream/2018-04-19T16:40:37.833
this is proper way to get the trigger to be created on dynamodb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With