forked from michalkvasnicak/aws-lambda-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
139 lines (132 loc) · 3.81 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
service: graphql-server-demo # NOTE: update this with your service name
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:
wsHandler:
handler: index.handleWebSocket
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
- websocket:
route: $default
eventProcessorHandler:
handler: index.handleEvents
events:
- stream:
enabled: true
type: dynamodb
arn:
Fn::GetAtt: [EventsDynamoDBTable, StreamArn]
# this one is optional (if you want to support HTTP)
httpHandler:
handler: index.handleHTTP
events:
- http:
path: /
method: any
cors: true
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
# This one is optional (all events have 2 hours of lifetime in ttl field but enabling TTL is up to you)
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true