-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
129 lines (124 loc) · 3.72 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
service: serverless-user-store
custom:
defaultStage: dev
userTable: 'serverless-user-store-${self:provider.stage}-user'
userBucket: 'serverless-user-store-${self:provider.stage}-user-unique' # needs a globally unique name
subscriptionTable: 'serverless-user-store-${self:provider.stage}-subscription'
passwordTable: 'serverless-user-store-${self:provider.stage}-password'
storeType: S3 # S3 or DynamoDB
debugLogs: true
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, self:custom.defaultStage}
region: us-east-1
memorySize: 512 # default is 1024
timeout: 30 # max for API Gateway
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:DeleteItem
Resource:
- 'arn:aws:dynamodb:*:*:table/${self:custom.userTable}'
- 'arn:aws:dynamodb:*:*:table/${self:custom.subscriptionTable}'
- 'arn:aws:dynamodb:*:*:table/${self:custom.passwordTable}'
- Effect: Allow
Action:
- s3:ListBucket
- s3:PutObject
- s3:GetObject
- s3:DeleteObject
Resource:
- 'arn:aws:s3:::${self:custom.userBucket}'
- 'arn:aws:s3:::${self:custom.userBucket}/*'
- Effect: Allow
Action: 'execute-api:Invoke'
Resource: 'arn:aws:execute-api:*:*:*'
environment:
USER_TABLE: ${self:custom.userTable}
USER_BUCKET: ${self:custom.userBucket}
SUBSCRIPTION_TABLE: ${self:custom.subscriptionTable}
PASSWORD_TABLE: ${self:custom.passwordTable}
REGION: ${self:provider.region}
DEBUG: ${self:custom.debugLogs}
STORE_TYPE: ${self:custom.storeType}
STAGE: ${self:provider.stage}
plugins:
# temp fix to hot reload issue (see https://github.com/dherault/serverless-offline/issues/864)
# is --useChildProcesses flag (see package.json)
- serverless-plugin-typescript
- serverless-offline
functions:
authorizerFunction:
handler: src/index.authorizerHandler
httpApiHandler:
handler: src/index.httpApiHandler
events:
- http:
path: api/
method: ANY
authorizer:
name: authorizerFunction
resultTtlInSeconds: 3200
- http:
path: "api/{proxy+}"
method: ANY
authorizer:
name: authorizerFunction
resultTtlInSeconds: 3200
httpHandler:
handler: src/index.httpHandler
events:
- http:
path: /
method: ANY
- http:
path: "{proxy+}"
method: ANY
webSocketsHandler:
handler: src/index.webSocketsHandler
events:
- websocket: $connect
- websocket: $disconnect
- websocket: $default
resources:
Resources:
UserTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.userTable}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
SubscriptionTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.subscriptionTable}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
PasswordTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.passwordTable}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
UserBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.userBucket} # must be globally unique