-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathserverless.yml
186 lines (171 loc) · 5.28 KB
/
serverless.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
176
177
178
179
180
181
182
183
184
185
186
service: cloudcam
plugins:
- serverless-python-requirements
- serverless-pseudo-parameters
- serverless-stack-output
- serverless-iam-roles-per-function
custom:
cloudcam:
s3_thumb_bucket_name: '#{AWS::StackName}-thumbs'
janus:
hosted_zone_domain: cloudcamdev.int80.biz
hosted_zone_id: Z28O6A5M6DDPL6
instance_name_prefix: '#{AWS::StackName}-stream'
ui_bucket_name: '#{AWS::StackName}-ui'
defaultLambdaMemorySize: 256
output:
file: ui/src/aws-stack.json
pythonRequirements:
dockerizePip: false
slim: true
useDownloadCache: true
useStaticCache: true
# noDeploy:
# - boto3
# - botocore
# - docutils
# customDomain:
# domainName: cloudcam.io
# stage: ${self:provider.stage}
# createRoute53Record: true
provider:
name: aws
runtime: python3.6
stage: ${opt:stage, 'dev'}
# profile: default
region: eu-central-1
variableSyntax: "\\${((?!(iot)|(AWS))[ ~:a-zA-Z0-9._@'\",\\-\\/\\(\\)]+?)}"
iamRoleStatements:
- Effect: Allow
Action: secretsmanager:GetSecretValue
Resource: "arn:aws:secretsmanager:#{AWS::Region}:#{AWS::AccountId}:secret:myservice/*"
package:
include:
- cloudcam/**
- '!**/__pycache__/**'
exclude:
- '**'
- node_modules/**
- venv/**
- '**/__pycache__/**'
- ".#*"
functions:
IoTListThings:
memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
timeout: 10
handler: cloudcam.iot_list_things.handler
events:
- http: GET /list_things
iamRoleStatements:
- Effect: Allow
Action:
- iot:ListPrincipalThings
Resource: '*'
IoTProvisionThing:
handler: cloudcam/iot_provision_thing.handler
timeout: 10
memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
environment:
CAMERA_IOT_POLICY_NAME: !Ref CameraIoTPolicy
iamRoleStatements:
- Effect: Allow
Action:
- iot:DescribeEndpoint
- iot:AttachPolicy
- iot:CreateThing
- iot:CreateKeysAndCertificate
- iot:AttachThingPrincipal
- iot:DetachPolicy
- iot:CreatePolicy
- iot:DeletePolicy
Resource: '*'
# unused - should delete
IoTAttachCameraPolicy:
memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
handler: cloudcam/iot_attach_camera_policy.handler
environment:
CAMERA_IOT_POLICY_NAME: !Ref CameraIoTPolicy
iamRoleStatements:
- Effect: Allow
Action:
- iot:DescribeEndpoint
- iot:AttachPolicy
- iot:UpdateThing
Resource: '*'
# unused - should delete
IoTAttachUserPolicy:
memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
handler: cloudcam/iot_attach_user_policy.handler
environment:
USER_IOT_POLICY_NAME: !Ref UserIoTPolicy
iamRoleStatements:
- Effect: Allow
Action:
- iot:AttachPolicy
Resource: '*'
CognitoPresignup:
handler: cloudcam/cognito_presignup.handler
memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
environment:
USER_IOT_POLICY_NAME: !Ref UserIoTPolicy
iamRoleStatements:
- Effect: Allow
Action:
- iot:AttachPolicy
Resource: '*'
ThumbStore:
handler: cloudcam/iot_request_thumb.handler
timeout: 10
environment:
S3_THUMB_BUCKET_NAME: ${self:custom.cloudcam.s3_thumb_bucket_name}
events:
- iot:
name: ThumbStoreEvent
sql: "SELECT * FROM 'cloudcam/thumb/request/*'"
- iot:
name: ThumbStoreConnectedEvent
sql: "SELECT * FROM '$aws/events/presence/connected/#'"
iamRoleStatements:
- Action:
- s3:GetObject
- s3:PutObject
Effect: Allow
Resource: !Sub 'arn:aws:s3:::#{ThumbBucket}/*'
- Effect: Allow
Action:
- iot:Publish
- iot:Connect
- iot:UpdateThingShadow
Resource:
- '*'
# JanusStartStream:
# role: !GetAtt [JanusStartStreamLambdaRole, Arn]
# handler: cloudcam/janus_start_stream.handler
# timeout: 10
# memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
# environment:
# JANUS_HOSTED_ZONE_DOMAIN: ${self:custom.cloudcam.janus.hosted_zone_domain}
# JANUS_INSTANCE_NAME_PREFIX: ${self:custom.cloudcam.janus.instance_name_prefix}
# JanusStopStream:
# role: !GetAtt [JanusStopStreamLambdaRole, Arn]
# handler: cloudcam/janus_stop_stream.handler
# timeout: 10
# memorySize: ${self:custom.cloudcam.defaultLambdaMemorySize}
# JanusScaleLightsail:
# role: !GetAtt [JanusScaleLightsailLambdaRole, Arn]
# name: ${self:provider.stage}-janus_scale_lightsail
# handler: cloudcam/janus_scale_lightsail.handler
# timeout: 300
# environment:
# LIGHTSAIL_AZS: !Ref LightsailAzs
# LIGHTSAIL_BLUEPRINT_ID: !Ref LightsailBlueprintId
# LIGHTSAIL_BUNDLE_ID: !Ref LightsailBundleId
# LIGHTSAIL_JANUS_IMAGE: !Ref LightsailJanusImage
# JANUS_HOSTED_ZONE_ID: ${self:custom.cloudcam.janus.hosted_zone_id}
# JANUS_HOSTED_ZONE_DOMAIN: ${self:custom.cloudcam.janus.hosted_zone_domain}
# JANUS_INSTANCE_NAME_PREFIX: ${self:custom.cloudcam.janus.instance_name_prefix}
resources:
- ${file(cloudformation/iot.yml)}
- ${file(cloudformation/s3.yml)}
- ${file(cloudformation/cognito.yml)}
- ${file(cloudformation/outputs.yml)}