-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
74 lines (69 loc) · 1.71 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
service:
name: ${env:SERVICE_NAME}
provider:
name: aws
runtime: nodejs8.10
region: ap-northeast-2
stage: ${self:custom.stage}
iamRoleStatements:
- Effect: "Allow"
Action:
- "execute-api:ManageConnections"
Resource:
- "arn:aws:execute-api:*:*:**/@connections/*"
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:DeleteItem"
- "dynamodb:Scan"
Resource:
- Fn::GetAtt: [ConnectionTable, Arn]
environment:
CONNECTION_TABLE_NAME: ${self:custom.connectionTableName}
API_PATH: ${env:API_PATH, ""}
plugins:
- serverless-webpack
custom:
webpack:
includeModules: # enable auto-packing of external modules
forceExclude:
- aws-sdk
connectionTableName: ${env:CONNECTION_TABLE_NAME, "ConnectionIds_${env:SERVICE_NAME}"}
stage: ${env:STAGE, opt:stage, "dev"}
functions:
connect:
handler: src/handler.connect
timeout: 12
memorySize: 256
events:
- websocket:
route: $connect
disconnect:
handler: src/handler.disconnect
timeout: 12
memorySize: 256
events:
- websocket:
route: $disconnect
broadcast:
handler: src/handler.broadcast
timeout: 6
memorySize: 128
events:
- websocket:
route: $default
resources:
Resources:
ConnectionTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.connectionTableName}
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
KeySchema:
- AttributeName: connectionId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5