/
serverless.yml
191 lines (188 loc) · 6.5 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
service: yame-api
custom:
localbucket: yame-local
devbucket: yame-dev
customDomain:
domainName: ${self:custom.domainNames.${self:provider.stage}}
certificateName: ${self:custom.certificateNames.${self:provider.stage}}
basePath: ''
stage: ${self:provider.stage}
createRoute53Record: true
domainNames:
dev: graphql.dev.yame.io
prod: graphql.yame.io
certificateNames:
dev: '*.dev.yame.io'
prod: '*.yame.io'
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage}
region: ap-southeast-2
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:Query
- dynamodb:UpdateItem
- dynamodb:PutItem
Resource: 'arn:aws:dynamodb:${self:provider.region, self:provider.region}:*:table/*'
- Effect: Allow
Action:
- s3:*
Resource: 'arn:aws:s3:::${self:custom.localbucket}/*'
- Effect: Allow
Action:
- s3:*
Resource: 'arn:aws:s3:::${self:custom.localbucket}'
- Effect: Allow
Action:
- s3:*
Resource: 'arn:aws:s3:::${self:custom.devbucket}/*'
- Effect: Allow
Action:
- s3:*
Resource: 'arn:aws:s3:::${self:custom.devbucket}'
- Effect: Allow
Action:
- logs:*
Resource: '*'
functions:
app:
handler: pack/handler.handler
events:
- http:
path: /{proxy+}
method: ANY
cors: true
contentHandling: CONVERT_TO_TEXT
environment:
FB_APP_ID: ${env:FB_APP_ID}
FB_APP_SECRET: ${env:FB_APP_SECRET}
BUCKET: ${env:BUCKET}
DOC_PERMALINKS_TABLE: ${env:DOC_PERMALINKS_TABLE}
USER_PROFILE_TABLE: ${env:USER_PROFILE_TABLE}
STAGE: ${self:provider.stage}
plugins:
- serverless-offline
- serverless-domain-manager
package:
exclude:
- src/**
- dist/**
- fonts/**
- node_modules/**
- blob/**
- ./*
include:
- pack/handler.js
resources:
Resources:
DocPermalinksTableLocal:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: permalink
AttributeType: S
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: DocPermalinks-local
GlobalSecondaryIndexes:
- IndexName: userIdPermalinkIndex
KeySchema:
- AttributeName: userId
KeyType: HASH
- AttributeName: permalink
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
DocPermalinksTableDev:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: permalink
AttributeType: S
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: DocPermalinks-dev
GlobalSecondaryIndexes:
- IndexName: userIdPermalinkIndex
KeySchema:
- AttributeName: userId
KeyType: HASH
- AttributeName: permalink
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
UserProfileTableLocal:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: username
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: UserProfile-local
GlobalSecondaryIndexes:
- IndexName: nameIndex
KeySchema:
- AttributeName: username
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
UserProfileTableDev:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: username
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: UserProfile-dev
GlobalSecondaryIndexes:
- IndexName: nameIndex
KeySchema:
- AttributeName: username
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1