-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
83 lines (77 loc) · 2.25 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
service: serverless-deeplens
package:
include:
- src/**
exclude:
- node_modules/**
plugins:
- serverless-plugin-include-dependencies
custom:
iotTopic: '$aws/things/deeplens_EopDct5XR7CEAaZRYhEZzw/infer'
includeDependencies:
always:
- 'src/lib/**'
- 'src/**'
provider:
name: aws
runtime: nodejs8.10
stackName: ${self:service}-${self:provider.stage}
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
iamRoleStatements:
- Effect: Allow
Action:
- "execute-api:ManageConnections"
Resource:
- "arn:aws:execute-api:*:*:**/@connections/*"
- Effect: Allow
Action:
- "dynamodb:PutItem"
- "dynamodb:GetItem"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- "dynamodb:Query"
- "dynamodb:Scan"
Resource:
- Fn::GetAtt: [DeepLensConnectionsTable, Arn]
- Fn::Join:
- "/"
- - Fn::GetAtt: [DeepLensConnectionsTable, Arn]
- "*"
environment:
# TODO : Figure out how to get the websocket api ID here and set the WSAPI_NAME variable.
WSAPI_NAME: "https://__UPDATE__.execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}"
DB_TABLE:
Ref: DeepLensConnectionsTable
websocketApiName: websocket-deeplens-${self:provider.stage}
websocketApiRouteSelectionExpression: $request.body.action
functions:
connectionManager:
handler: src/handlers/connectionManager.handler
events:
- websocket:
route: $connect
#authorizer: authorizerFunc # references the authorizerFunc function below
- websocket:
route: $disconnect
authorizerFunc:
handler: src/handlers/authorizerFunc.handler
sendMessage:
handler: src/handlers/sendMessage.handler
events:
- iot:
sql: "SELECT * FROM '${self:custom.iotTopic}'"
resources:
Resources:
DeepLensConnectionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
KeySchema:
- AttributeName: connectionId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5