-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathtemplate_lite.yaml
316 lines (300 loc) · 16.8 KB
/
template_lite.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@
# Authored by Runpeng Liu,
# Brain Power (2018).
# This template launches a 'Lite' version of the web app, which only includes Webcam to KVS functionality.
#
# The 'Full' version of the web app can be launched using `template.yaml`,
# which additionally includes Rekognition Video face detection and motion analytics features.
#
# To deploy for the first time, and for each update,
# run both of the following commands in order:
#
# aws cloudformation package \
# --template-file template_lite.yaml \
# --output-template-file packaged-template_lite.yaml \
# --s3-bucket <your-s3-bucket-name>
#
# aws cloudformation deploy \
# --template-file packaged-template_lite.yaml \
# --stack-name <STACK_NAME> \
# --capabilities CAPABILITY_IAM
AWSTemplateFormatVersion: '2010-09-09'
# Using Serverless Application Model (SAM) CF template definition
# See specification: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md
Transform: 'AWS::Serverless-2016-10-31'
Globals:
Function:
Timeout: 300 # seconds
MemorySize: 1024 # MB
Environment:
Variables:
KVS_STREAM_NAME: !Ref KVSStreamName
PRODUCER_START_TIMESTAMP_KEY: "producer_start_timestamp"
UPLOADS_BUCKET_NAME: !Sub "${ApplicationName}-uploads-${AWS::AccountId}"
WEBAPP_BUCKET_NAME: !Sub "${ApplicationName}-webapp-${AWS::AccountId}"
TARGET_FRAME_RATE: !Ref TargetFrameRate
Parameters:
ShouldBootstrapWebApp:
Type: String
Default: true
AllowedValues: [true, false]
Description: >
If set to True, static files for web app will be cloned from publicly available demo artifacts for this project.
This setting must be True if deploying using the CloudFormation online console.
Set this to False if you want to modify the default dashboard app files and/or deploy via the command line.
ShouldDeleteVideoFragments:
Type: String
Default: true
AllowedValues: [true, false]
Description: >
If set to True, archived video files and stream fragments generated by web app
will be deleted when this stack is deleted.
ApplicationName:
Type: String
Default: brain-power-fidgetology-demo
AllowedPattern: "^(?![0-9]+$)(?!.*-$)(?!-)[a-z0-9-]{4,48}$"
Description: >
Enter a DNS compatible label.
Allowed characters: lowercase letters [a-z], numbers [0-9], and hyphens [-] only.
Must begin and end with alphanumeric character.
TargetFrameRate:
Type: Number
Default: 10
MinValue: 5
MaxValue: 20
Description: >
Specify target frame rate (in FPS) that webcam should stream at.
KVSStreamName:
Type: String
Default: browser-webcam-demo-kvs
Description: >
Name of Kinesis Video Stream that will be created with this stack.
Change to the name of an existing Kinesis Video Stream if you do not want this stack to create a new one.
Conditions:
BootstrapWebApp: !Equals [ !Ref ShouldBootstrapWebApp, true ]
Resources:
####### S3 Buckets #######
UploadsBucket:
Type: AWS::S3::Bucket
Description: Bucket that stores static videos and stream fragments uploaded using web app
DeletionPolicy: Retain
Properties:
CorsConfiguration:
CorsRules:
- AllowedHeaders: ['*']
AllowedMethods: [GET,POST,PUT,DELETE,HEAD]
AllowedOrigins: ['*']
BucketName: !Sub "${ApplicationName}-uploads-${AWS::AccountId}"
WebAppBucket:
Type: AWS::S3::Bucket
Description: Bucket that hosts static content of web app
DeletionPolicy: Retain
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
BucketName: !Sub "${ApplicationName}-webapp-${AWS::AccountId}"
WebAppBootstrapperLambda:
Type: AWS::Serverless::Function
Condition: BootstrapWebApp
Properties:
Description: >
Uploads dashboard static files to web app bucket when stack is created.
Deletes web app bucket when stack is deleted.
Deletes video fragments generated by web app when when stack is deleted.
Handler: bootstrapper.handler
Runtime: nodejs10.x
CodeUri: ./dashboard
FunctionName: !Sub "${ApplicationName}-WebAppBootstrapper"
Environment:
Variables:
ShouldDeleteVideoFragments: !Ref ShouldDeleteVideoFragments
Timeout: 20
Policies:
- AWSLambdaExecute
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- iam:PassRole
- iam:GetRole
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/${ApplicationName}*"
- Effect: Allow
Action:
- s3:ListBucket
- s3:DeleteBucket
Resource:
- !Sub "arn:aws:s3:::${ApplicationName}-webapp-${AWS::AccountId}"
- !Sub "arn:aws:s3:::${ApplicationName}-uploads-${AWS::AccountId}"
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
- s3:ListObjects
- s3:DeleteObject
Resource:
- !Sub "arn:aws:s3:::${ApplicationName}-webapp-${AWS::AccountId}/*"
- !Sub "arn:aws:s3:::${ApplicationName}-uploads-${AWS::AccountId}/*"
WebAppBootstrapper:
Type: Custom::WebAppBootstrapper # Custom resource definition
Description: >
A custom resource that uploads dashboard static files to web app bucket upon stack creation.
Properties:
ServiceToken: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${ApplicationName}-WebAppBootstrapper"
DependsOn:
- WebAppBucket
- UploadsBucket
- WebAppBootstrapperLambda
####### Serverless Lambda Functions #######
MKVConverterLambda:
Type: AWS::Serverless::Function
Properties:
Description: Converts static video uploads to streamable .MKV format for ingestion by Kinesis Video Streams
Handler: index.handler
Runtime: nodejs10.x
CodeUri: ./lambda/MKVConvert
MemorySize: 3000
Environment:
Variables:
FFMPEG_CMD: '-i %i -vcodec copy -an %o'
Policies:
- AWSLambdaExecute
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource: !Sub "arn:aws:s3:::${ApplicationName}-uploads-${AWS::AccountId}/*"
Events:
VideoUploadEvent:
Type: S3
Properties:
Bucket: !Ref UploadsBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: raw_uploads/
S3ToKVSLambda:
Type: AWS::Serverless::Function
Properties:
Description: Artificially streams static .MKV video files in S3 to Kinesis Video Streams
Handler: com.brainpower.fidgetology.demo.LambdaFunctionHandler::handleRequest
Runtime: java8
CodeUri: ./lambda/S3ToKVS/S3ToKVS.jar
MemorySize: 3000
Policies:
- AWSLambdaExecute
- AmazonKinesisVideoStreamsFullAccess
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource: !Sub "arn:aws:s3:::${ApplicationName}-uploads-${AWS::AccountId}/*"
Events:
VideoConvertedEvent:
Type: S3
Properties:
Bucket: !Ref UploadsBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: suffix
Value: .mkv
- Name: prefix
Value: mkv_uploads/
WebAPI:
Type: AWS::Serverless::Function
Properties:
Description: RESTful API endpoint for web app using Amazon API Gateway
Handler: index.handler
Runtime: nodejs10.x
CodeUri: ./lambda/WebApi
MemorySize: 3000
Environment:
Variables:
FFMPEG_CMD: '-r %r -f image2 -s 640x480 -i %i -vcodec libx264 -crf 25 -pix_fmt yuv420p %o'
Policies:
- AWSLambdaExecute
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource: !Sub "arn:aws:s3:::${ApplicationName}-uploads-${AWS::AccountId}/*"
Events:
GetStatic:
Type: Api
Properties:
Path: /App/{proxy+}
Method: get
GetConfig:
Type: Api
Properties:
Path: /Config
Method: get
ProcessDataFrames:
Type: Api
Properties:
Path: /FrameData
Method: post
Outputs:
WebAppSecureURL:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/App/index.html"
Description: Public URL for web dashboard hosted on S3 and fronted by API Gateway.
APIEndpoint:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"
Description: REST API endpoint for web app