-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
250 lines (242 loc) · 8.62 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
service: authJwt
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
plugins:
- serverless-offline
provider:
name: aws
runtime: java8
stage: ${opt:stage, 'dev'}
environment:
secret: ${ssm:/${opt:stage, 'dev'}/jwt/algorithm/secret~true}
issuer: ${ssm:/${opt:stage, 'dev'}/jwt/issuer~true}
expirationInMinutes: ${ssm:/${opt:stage, 'dev'}/jwt/expirationInMinutes}
nbSeconds: ${ssm:/${opt:stage, 'dev'}/jwt/nbSeconds}
audience: ${ssm:/${opt:stage, 'dev'}/jwt/audience}
salt: ${ssm:/${opt:stage, 'dev'}/jwt/salt~true}
apiKeys:
- ${opt:stage, self:provider.stage}-testKey
usagePlan:
quota:
limit: 500
offset: 2
period: MONTH
throttle:
burstLimit: 50
rateLimit: 30
iamRoleStatements: # permissions for all of your functions can be set here
- Effect: Allow
Action: # Gives permission to DynamoDB tables in a specific region
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
#Resource: "arn:aws:dynamodb:${self:custom.region}:${AWS::AccountId}:table/Users"
Resource:
- Fn::Join: [":", [ "arn", "aws", "dynamodb", { "Ref": "AWS::Region" }, { Ref: "AWS::AccountId" }, "table/Users" ]]
# you can overwrite defaults here
# stage: dev
# region: us-east-1
# you can define service wide environment variables here
# environment:
# variable1: value1
custom:
region: ${opt:region, self:provider.region}
# you can add packaging information here
# Make sure to run "sbt assembly" to create a jar file
# with all your dependencies and put that jar file name here.
package:
artifact: target/scala-2.12/authJwt.jar
functions:
customAuthorizerHandler:
handler: authJwt.CustomAuthorizerHandler
#events:
# - http:
# path: CustomAuthorizerHandler
# method: post
# cors: true
hello:
handler: authJwt.HelloWorld
events:
- http:
path: helloWorld
method: get
cors: true
authorizer: customAuthorizerHandler
login:
handler: authJwt.LoginHandler
events:
- http:
path: login
method: post
cors: true
private: true
resources:
Resources:
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: ${self:service}-${opt:stage, self:provider.stage}
#### Gateway Response INIT
GatewayResponseDefault400:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: DEFAULT_4XX
ResponseTemplates:
application/json: "{\"errorCode\":901,\"message\":$context.error.messageString}"
GatewayResponseDefault500:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: DEFAULT_5XX
ResponseTemplates:
application/json: "{\"errorCode\":902,\"message\":$context.error.messageString}"
GatewayResponseAccessDeied:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: ACCESS_DENIED
ResponseTemplates:
application/json: "{\"errorCode\":903,\"message\":$context.error.messageString}"
GatewayResponseApiConfigurationError:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: API_CONFIGURATION_ERROR
ResponseTemplates:
application/json: "{\"errorCode\":904,\"message\":$context.error.messageString}"
GatewayResponseAuthorizerConfigurationError:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: AUTHORIZER_CONFIGURATION_ERROR
ResponseTemplates:
application/json: "{\"errorCode\":905,\"message\":$context.error.messageString}"
GatewayResponseAuthorizerFailure:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: AUTHORIZER_FAILURE
ResponseTemplates:
application/json: "{\"errorCode\":906,\"message\":$context.error.messageString}"
GatewayResponseBadRequestBody:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: BAD_REQUEST_BODY
ResponseTemplates:
application/json: "{\"errorCode\":907,\"message\":$context.error.messageString}"
GatewayResponseBadRequestParameters:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: BAD_REQUEST_PARAMETERS
ResponseTemplates:
application/json: "{\"errorCode\":908,\"message\":$context.error.messageString}"
GatewayResponseExpiredToken:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: EXPIRED_TOKEN
ResponseTemplates:
application/json: "{\"errorCode\":909,\"message\":$context.error.messageString}"
GatewayResponseIntegrationFailure:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: INTEGRATION_FAILURE
ResponseTemplates:
application/json: "{\"errorCode\":910,\"message\":$context.error.messageString}"
GatewayResponseIntegrationTimeout:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: INTEGRATION_TIMEOUT
ResponseTemplates:
application/json: "{\"errorCode\":911,\"message\":$context.error.messageString}"
GatewayResponseInvalidApiKey:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: INVALID_API_KEY
ResponseTemplates:
application/json: "{\"errorCode\":912,\"message\":$context.error.messageString}"
GatewayResponseInvalidSignature:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: INVALID_SIGNATURE
ResponseTemplates:
application/json: "{\"errorCode\":913,\"message\":$context.error.messageString}"
GatewayResponseMissingAuthenticationToken:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: MISSING_AUTHENTICATION_TOKEN
ResponseTemplates:
application/json: "{\"errorCode\":914,\"message\":$context.error.messageString}"
GatewayResponseQuotaExceeded:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: QUOTA_EXCEEDED
ResponseTemplates:
application/json: "{\"errorCode\":915,\"message\":$context.error.messageString}"
GatewayResponseRequestTooLarge:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: REQUEST_TOO_LARGE
ResponseTemplates:
application/json: "{\"errorCode\":916,\"message\":$context.error.messageString}"
GatewayResponseResourceNotFound:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: RESOURCE_NOT_FOUND
ResponseTemplates:
application/json: "{\"errorCode\":917,\"message\":$context.error.messageString}"
GatewayResponseThrottled:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: THROTTLED
ResponseTemplates:
application/json: "{\"errorCode\":918,\"message\":$context.error.messageString}"
GatewayResponseUnauthorized:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: UNAUTHORIZED
ResponseTemplates:
application/json: "{\"errorCode\":919,\"message\":$context.error.messageString}"
GatewayResponseUnauthorizedMediType:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
RestApiId:
Ref: 'ApiGatewayRestApi'
ResponseType: UNSUPPORTED_MEDIA_TYPE
ResponseTemplates:
application/json: "{\"errorCode\":920,\"message\":$context.error.messageString}"
#### Gateway Response END