-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathtemplate.yaml
74 lines (68 loc) · 2.02 KB
/
template.yaml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
DynamoDB Streams batch processing demo
Globals:
Function:
Timeout: 20
Runtime: java11
MemorySize: 512
Tracing: Active
Architectures:
- x86_64
Environment:
Variables:
POWERTOOLS_LOG_LEVEL: INFO
POWERTOOLS_LOGGER_SAMPLE_RATE: 1.0
POWERTOOLS_LOGGER_LOG_EVENT: true
Resources:
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
DemoDynamoDBWriter:
Type: AWS::Serverless::Function
Properties:
CodeUri: ../..
Handler: org.demo.batch.dynamo.DynamoDBWriter::handleRequest
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: ddbstreams-demo
TABLE_NAME: !Ref DynamoDBTable
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref DynamoDBTable
Events:
CWSchedule:
Type: Schedule
Properties:
Schedule: 'rate(1 minute)'
Name: !Join [ "-", [ "ddb-writer-schedule", !Select [ 0, !Split [ -, !Select [ 2, !Split [ /, !Ref AWS::StackId ] ] ] ] ] ]
Description: Write records to DynamoDB via a Lambda function
Enabled: true
DemoDynamoDBStreamsConsumerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ../..
Handler: org.demo.batch.dynamo.DynamoDBStreamBatchHandler::handleRequest
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: ddbstreams-batch-demo
Policies: AWSLambdaDynamoDBExecutionRole
Events:
Stream:
Type: DynamoDB
Properties:
Stream: !GetAtt DynamoDBTable.StreamArn
BatchSize: 100
StartingPosition: TRIM_HORIZON