-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdynamodb-stream-processor.yaml
More file actions
56 lines (52 loc) · 1.6 KB
/
Copy pathdynamodb-stream-processor.yaml
File metadata and controls
56 lines (52 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >
AWS Lambda trigger to process new items in a stream from a DynamoDB table.
Parameters:
enableDEBUGGER:
Description: Do you want to enable logging.
Default: "False"
Type: String
AllowedValues: ["True", "False"]
ConstraintDescription: Must be boolean.
Resources:
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: Username
AttributeType: S
- AttributeName: Timestamp
AttributeType: S
KeySchema:
- AttributeName: Username
KeyType: HASH
- AttributeName: Timestamp
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
DynamoDBStreamProcessor:
Type: AWS::Serverless::Function
Properties:
Description: 'An AWS Lambda trigger to process a stream from a DynamoDB table.'
Handler: dynamodb-stream-processor.lambda_handler
Runtime: python3.7
CodeUri: ./src/dynamodb-stream-processor.py
Environment:
Variables:
ENABLE_DEBUG:
Ref: enableDEBUGGER
MemorySize: 128
Timeout: 3
Events:
Stream:
Type: DynamoDB
Properties:
Stream: !GetAtt DynamoDBTable.StreamArn
BatchSize: 3 # How many items we want to process at once
StartingPosition: TRIM_HORIZON
Policies:
- AWSLambdaDynamoDBExecutionRole # Managed Policy