forked from michalkvasnicak/aws-lambda-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
159 lines (150 loc) · 4.07 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
service: graphql-server-demo # NOTE: update this with your service name
custom:
dynamodb:
stages:
- dev
start:
inMemory: true
migrate: true
noStart: false
dynamodbStream:
host: localhost
port: 8000
# this fixes the problem with missing region
region: eu-central-1
pollForever: true
streams:
- table: Events
functions:
- dynamoDBStreamHandler
provider:
name: aws
runtime: nodejs10.x
region: eu-central-1 # NOTE: change with your preferred region
iamRoleStatements:
- Effect: Allow
Action:
- execute-api:ManageConnections
Resource: 'arn:aws:execute-api:*:*:*/development/POST/@connections/*'
- Effect: Allow
Action:
- dynamodb:DeleteItem
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource: !GetAtt ConnectionsDynamoDBTable.Arn
- Effect: Allow
Action:
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
Resource: !GetAtt EventsDynamoDBTable.StreamArn
- Effect: Allow
Action:
- dynamodb:PutItem
Resource: !GetAtt EventsDynamoDBTable.Arn
- Effect: Allow
Action:
- dynamodb:BatchWriteItem
- dynamodb:DeleteItem
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:Query
- dynamodb:Scan
Resource: !GetAtt SubscriptionsDynamoDBTable.Arn
- Effect: Allow
Action:
- dynamodb:BatchWriteItem
- dynamodb:DeleteItem
- dynamodb:GetItem
- dynamodb:PutItem
Resource: !GetAtt SubscriptionOperationsDynamoDBTable.Arn
functions:
httpHandler:
handler: src/index.handleHttp
events:
- http:
path: /
method: any
cors: true
webSocketHandler:
handler: src/index.handleWebSocket
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
- websocket:
route: $default
dynamoDBStreamHandler:
handler: src/index.handleDynamoDBStream
events:
- stream:
enabled: true
type: dynamodb
arn:
Fn::GetAtt: [EventsDynamoDBTable, StreamArn]
resources:
Resources:
ConnectionsDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
# see DynamoDBConnectionManager
TableName: Connections
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
# connection id
- AttributeName: id
KeyType: HASH
SubscriptionsDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
# see DynamoDBSubscriptionManager
TableName: Subscriptions
AttributeDefinitions:
- AttributeName: event
AttributeType: S
- AttributeName: subscriptionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: event
KeyType: HASH
- AttributeName: subscriptionId
KeyType: RANGE
SubscriptionOperationsDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
# see DynamoDBSubscriptionManager
TableName: SubscriptionOperations
AttributeDefinitions:
- AttributeName: subscriptionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: subscriptionId
KeyType: HASH
EventsDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
# see DynamoDBEventStore
TableName: Events
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
# see ISubscriptionEvent
AttributeDefinitions:
- AttributeName: id
AttributeType: S
StreamSpecification:
StreamViewType: NEW_IMAGE
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-plugin-offline-dynamodb-stream
- serverless-offline