-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
56 lines (54 loc) · 1.36 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
service: aws-serverless-websockets
provider:
name: aws
runtime: nodejs12.x
environment:
CONNECTION_DB_TABLE: ${self:resources.Resources.MyAppTable.Properties.TableName}
iamRoleStatements:
- Effect: Allow
Action:
- "dynamodb:PutItem"
- "dynamodb:GetItem"
- "dynamodb:DeleteItem"
- "dynamodb:Scan"
Resource:
- Fn::GetAtt: [MyAppTable, Arn]
- Effect: Allow
Action:
- "execute-api:ManageConnections"
Resource:
- "arn:aws:execute-api:*:*:**/@connections/*"
functions:
connectHandler:
handler: handler.connectHandler
events:
- websocket:
route: $connect
disconnectHandler:
handler: handler.disconnectHandler
events:
- websocket:
route: $disconnect
defaultHandler:
handler: handler.defaultHandler
events:
- websocket:
route: $default
broadcastHandler:
handler: handler.broadcastHandler
events:
- websocket:
route: broadcastMessage
resources:
Resources:
MyAppTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: "connectionId"
AttributeType: "S"
KeySchema:
- AttributeName: "connectionId"
KeyType: "HASH"
BillingMode: PAY_PER_REQUEST
TableName: myAppConnectionTable