-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless-python.yml
175 lines (167 loc) · 4.37 KB
/
serverless-python.yml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
service: dynamodb-logs
disabledDeprecations:
- CLI_OPTIONS_SCHEMA
frameworkVersion: ^2.38.0
package:
individually: true
plugins:
- serverless-iam-roles-per-function
- serverless-offline
- serverless-offline-dynamodb-streams
- serverless-python-requirements
- serverless-offline-aws-eventbridge
- serverless-plugin-conditional-functions
custom:
serverless-offline-dynamodb-streams:
apiVersion: "2013-12-02"
endpoint: http://0.0.0.0:8000
region: us-east-1
accessKeyId: x
secretAccessKey: x
skipCacheInvalidation: false
readInterval: 1000
pythonRequirements:
slim: true
noDeploy:
- boto3
- botocore
- s3transfer
- urllib3
- jmespath
- dateutil
serverless-offline-aws-eventbridge:
port: 4010
debug: true
account: ""
region: us-east-1
accessKeyId: x
secretAccessKey: x
retryDelayMs: 1600
maximumRetryAttempts: 5
csm:
enabled:
local: true
port:
local: 31000
host:
local: 127.0.0.1
provider:
name: aws
deploymentBucket:
blockPublicAccess: true
serverSideEncryption: AES256
logRetentionInDays: 5
tracing:
lambda: true
iam:
role:
statements:
- Effect: Allow
Action:
- xray:PutTelemetryRecords
- xray:PutTraceSegments
Resource: "*"
lambdaHashingVersion: 20201221
environment:
AWS_CSM_ENABLED: ${self:custom.csm.enabled.${opt:stage}, false}
AWS_CSM_PORT: ${self:custom.csm.port.${opt:stage}, ''}
AWS_CSM_HOST: ${self:custom.csm.host.${opt:stage}, ''}
eventBridge:
useCloudFormation: true
tags:
commit: "${env:COMMIT_ID}"
functions:
saveToLocalDb:
enabled: '"${opt:stage, "local"}" == "local"'
runtime: nodejs14.x
handler: src/sqlite3.handler
events:
- eventBridge:
eventBus: !Ref eventBus
pattern:
source:
- "dynamodb-log"
detail-type:
- "stream changes"
eventHandler:
runtime: python3.8
timeout: 6
memorySize: 128
reservedConcurrency: 1
handler: src/handler.handler
environment:
DYNAMODB_LOGS_TABLE: "${opt:stage, 'local'}-dynamodb-logs"
DYNAMODB_CORE_TABLE: "${opt:stage, 'local'}-core"
package:
patterns:
- "!./**"
- "./src/handler.py"
iamRoleStatementsName: "dynamodb-logs-${opt:stage, 'local'}-event-handler"
iamRoleStatements:
- Effect: Allow
Action:
- "dynamodb:Query"
Resource:
- !Sub "arn:${AWS::Partition}:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${opt:stage, 'local'}-dynamodb-logs"
- Effect: Allow
Action:
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
Resource:
- !Sub "arn:${AWS::Partition}:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${opt:stage, 'local'}-core"
iamRoleStatementsInherit: true
events:
- eventBridge:
eventBus: !Ref eventBus
pattern:
source:
- "dynamodb-log"
detail-type:
- "stream changes"
detail:
log:
- users
type:
- signup
- addPhoneNumber
- verifyPhoneNumber
- addLocation
trigger:
runtime: python3.8
timeout: 6
memorySize: 128
handler: src/trigger.handler
package:
patterns:
- "!./**"
- "src/trigger.py"
iamRoleStatementsName: "dynamodb-logs-${opt:stage, 'local'}-trigger"
iamRoleStatements:
- Effect: Allow
Action:
- "events:PutEvents"
Resource:
- !Sub "arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/dynamodb-log"
iamRoleStatementsInherit: true
events:
- stream:
type: dynamodb
arn: !GetAtt dynamodb.StreamArn
batchSize: 25
batchWindow: 1
parallelizationFactor: 4
bisectBatchOnFunctionError: true
startingPosition: LATEST
resources:
Resources:
dynamodb: ${file(./dynamodb.yml)}
readmodel: ${file(./dynamodb.read.yml)}
eventBus: ${file(./event-bus.yml)}
eventBusArchive: ${file(./event-bus-archive.yml)}
Outputs:
eventBusArn:
Description: arn of eventbus
Value: !GetAtt eventBus.Arn
Export:
Name: eventBusArn