-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
143 lines (136 loc) · 4.12 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
org: upstandfm
app: api
service: channels-api
plugins:
- serverless-domain-manager
custom:
customDomain:
domainName: api.upstand.fm
basePath: channels
stage: ${opt:stage, 'prod'}
createRoute53Record: false
cors:
origin: '*'
authorizer:
arn: ${secrets:AUTH0_AUTHORIZER_ARN}
resultTtlInSeconds: 60
identitySource: method.request.header.Authorization
# Note that Bearer must be capitalized
identityValidationExpression: '^Bearer [-0-9a-zA-z\.]*$'
type: token
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'prod'}
region: ${opt:region, 'eu-central-1'}
cfnRole: ${secrets:CFN_ROLE_ARN}
memorySize: 128
timeout: 3
deploymentBucket:
name: upstandfm-deployments
serverSideEncryption: AES256
environment:
# Reuse TCP connection to reduce request latency
# For more info see:
# https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#24630
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
CORS_ALLOW_ORIGIN: ${self:custom.cors.origin}
# The ARN has the format "arn:aws:dynamodb:::table/tableName"
# Splitting on "/" gives us the name
WORKSPACES_TABLE_NAME:
'Fn::Select':
['1', { 'Fn::Split': ['/', '${state:infra.workspacesTableArn}'] }]
DEFAULT_CHANNELS_LIMIT: 10
DEFAULT_RECORDINGS_LIMIT: 20
CREATE_CHANNEL_SCOPE: 'create:channel'
READ_CHANNELS_SCOPE: 'read:channels'
READ_CHANNEL_SCOPE: 'read:channel'
READ_CHANNEL_RECORDINGS_SCOPE: 'read:channel-recordings'
# See: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_actions-resources-contextkeys.html
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:Query
Resource: ${state:infra.workspacesTableArn}
package:
exclude:
- ./*
- ./**/*.spec.js
include:
- node_modules
- src
functions:
createChannel:
handler: src/handler.createChannel
description: Creates a channel in the user's workspace
events:
- http:
method: post
path: /
cors: ${self:custom.cors}
authorizer: ${self:custom.authorizer}
getChannels:
handler: src/handler.getChannels
description: Gets all channels in the user's workspace
events:
- http:
method: get
path: /
request:
parameters:
queryStrings:
limit: false # optional query param
cursor: false # optional query param
cors: ${self:custom.cors}
authorizer: ${self:custom.authorizer}
getChannel:
handler: src/handler.getChannel
description: Gets a single channel in the user's workspace
events:
- http:
method: get
path: /{channelId}
request:
parameters:
paths:
channelId: true
cors: ${self:custom.cors}
authorizer: ${self:custom.authorizer}
getChannelRecordings:
handler: src/handler.getChannelRecordings
description: Gets all channel recordings
events:
- http:
method: get
path: /{channelId}/recordings
request:
parameters:
paths:
channelId: true
queryStrings:
limit: false # optional query param
cursor: false # optional query param
cors: ${self:custom.cors}
authorizer: ${self:custom.authorizer}
resources:
Resources:
GatewayResponseDefault4XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: 'ApiGatewayRestApi'
GatewayResponseDefault5XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_5XX
RestApiId:
Ref: 'ApiGatewayRestApi'