-
Notifications
You must be signed in to change notification settings - Fork 0
/
packaged.yaml
277 lines (277 loc) · 7.22 KB
/
packaged.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
AWSTemplateFormatVersion: '2010-09-09'
Description: Serverless Application Model - DBCC Application
Globals:
Function:
Environment:
Variables:
APP_NAME:
Ref: AppName
APP_VERSION:
Ref: AppVersion
DDB_TABLE:
Fn::Sub: ${AppName}-${Environment}
S3_BUCKET_NAME:
Fn::ImportValue: dbcConverterBucket
SQS_CONVERTER_QUEUE:
Fn::ImportValue: dbcConverterQueue
SQS_EMAIL_QUEUE:
Fn::ImportValue: dbcEmailQueue
Runtime: python3.7
Timeout: 30
Outputs:
ApplicationApi:
Description: API Gateway endpoint URL for the application
Value:
Fn::Sub: https://${ApplicationApi}.execute-api.${AWS::Region}.amazonaws.com/${Environment}/
dbccDynamoDbStreamArn:
Description: DynamoDB Stream ARN
Export:
Name: dbccDynamoDb-streamarn
Value:
Fn::GetAtt:
- dbccDynamoDb
- StreamArn
dbccDynamoDbTable:
Description: DynamoDB Table Name
Export:
Name: dbccDynamoDb
Value:
Ref: dbccDynamoDb
Parameters:
AppName:
Default: sam-dbcc-converter
Description: Name of the application
Type: String
AppVersion:
Default: v1
Description: Version of the application
Type: String
Environment:
Default: dev
Description: Name of the environment to deploy to
Type: String
Resources:
AppConverterFunction:
Properties:
AutoPublishAlias: live
CodeUri: s3://snowco-sam-eu-west-1/98692fbcc2d16bac53ee5c58e92a961f
DeploymentPreference:
Type: AllAtOnce
Events:
SqsEvent:
Properties:
BatchSize: 1
Queue:
Fn::ImportValue: dbcConverterQueue-ARN
Type: SQS
Handler: app.main
Policies:
- Statement:
- Action:
- dynamodb:*
Effect: Allow
Resource:
Fn::GetAtt:
- dbccDynamoDb
- Arn
- Action:
- s3:*
Effect: Allow
Resource: '*'
Version: '2012-10-17'
Type: AWS::Serverless::Function
AppProcessorFunction:
Properties:
AutoPublishAlias: live
CodeUri: s3://snowco-sam-eu-west-1/c713b3ae6cca09229fc74f948f1054d6
DeploymentPreference:
Type: AllAtOnce
Events:
SqsEvent:
Properties:
BatchSize: 1
Queue:
Fn::ImportValue: dbcConverterS3Queue-ARN
Type: SQS
Handler: app.main
Policies:
- Statement:
- Action:
- dynamodb:*
Effect: Allow
Resource:
Fn::GetAtt:
- dbccDynamoDb
- Arn
Version: '2012-10-17'
Type: AWS::Serverless::Function
AppVersionFunction:
Properties:
AutoPublishAlias: live
CodeUri: s3://snowco-sam-eu-west-1/ef9b8220b232d69f7f3235330da6050b
DeploymentPreference:
Hooks:
PostTraffic:
Ref: AppVersionPostTrafficHookFunction
PreTraffic:
Ref: AppVersionPreTrafficHookFunction
Type: AllAtOnce
Events:
Version:
Properties:
Method: get
Path: /version
RestApiId:
Ref: ApplicationApi
Type: Api
Handler: app.get_version
Type: AWS::Serverless::Function
AppVersionPostTrafficHookFunction:
Properties:
CodeUri: s3://snowco-sam-eu-west-1/5b704e2ebae2b29a0c9e7723e6b96e2b
DeploymentPreference:
Enabled: false
FunctionName: CodeDeployHook_postTrafficHook
Handler: test_handler.test_version_post_traffic
Policies:
- Statement:
- Action:
- codedeploy:PutLifecycleEventHookExecutionStatus
Effect: Allow
Resource: '*'
Version: '2012-10-17'
- Statement:
- Action:
- lambda:InvokeFunction
Effect: Allow
Resource:
Ref: AppVersionFunction.Version
Version: '2012-10-17'
Type: AWS::Serverless::Function
AppVersionPreTrafficHookFunction:
Properties:
CodeUri: s3://snowco-sam-eu-west-1/ef9b8220b232d69f7f3235330da6050b
DeploymentPreference:
Enabled: false
Environment:
Variables:
CurrentFunctionVersion:
Ref: AppVersionFunction.Version
FunctionName: CodeDeployHook_preTrafficHook
Handler: test_handler.test_version_pre_traffic
Policies:
- Statement:
- Action:
- codedeploy:PutLifecycleEventHookExecutionStatus
Effect: Allow
Resource: '*'
Version: '2012-10-17'
- Statement:
- Action:
- lambda:InvokeFunction
Effect: Allow
Resource:
Ref: AppVersionFunction.Version
Version: '2012-10-17'
Type: AWS::Serverless::Function
ApplicationApi:
Properties:
Name: ApplicationApi
StageName:
Ref: Environment
Type: AWS::Serverless::Api
ReturnEmailFunction:
Properties:
AutoPublishAlias: live
CodeUri: s3://snowco-sam-eu-west-1/f75a82ff734747440049bc67c3d07fc0
DeploymentPreference:
Type: AllAtOnce
Events:
SqsEvent:
Properties:
BatchSize: 1
Queue:
Fn::ImportValue: dbcEmailQueue-ARN
Type: SQS
Handler: app.main
Policies:
- Statement:
- Action:
- dynamodb:*
Effect: Allow
Resource:
Fn::GetAtt:
- dbccDynamoDb
- Arn
- Action:
- ses:*
Effect: Allow
Resource: '*'
- Action:
- s3:*
Effect: Allow
Resource: '*'
Version: '2012-10-17'
Type: AWS::Serverless::Function
StreamProcessorFunction:
Properties:
AutoPublishAlias: live
CodeUri: s3://snowco-sam-eu-west-1/6193f58e9b260aea21f852ac57286aed
DeploymentPreference:
Type: AllAtOnce
Events:
DdbEvent:
Properties:
BatchSize: 1
Enabled: true
StartingPosition: LATEST
Stream:
Fn::GetAtt:
- dbccDynamoDb
- StreamArn
Type: DynamoDB
Handler: app.main
Policies:
- Statement:
- Action:
- dynamodb:*
Effect: Allow
Resource:
Fn::GetAtt:
- dbccDynamoDb
- Arn
- Action:
- dynamodb:*
Effect: Allow
Resource:
Fn::GetAtt:
- dbccDynamoDb
- StreamArn
- Action:
- s3:*
Effect: Allow
Resource: '*'
- Action:
- sqs:*
Effect: Allow
Resource:
Fn::ImportValue: dbcConverterQueue-ARN
Version: '2012-10-17'
Type: AWS::Serverless::Function
dbccDynamoDb:
Properties:
AttributeDefinitions:
- AttributeName: messageId
AttributeType: S
KeySchema:
- AttributeName: messageId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
StreamSpecification:
StreamViewType: NEW_IMAGE
TableName:
Fn::Sub: ${AppName}-${Environment}
Type: AWS::DynamoDB::Table
Transform: AWS::Serverless-2016-10-31