This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
96 lines (91 loc) · 2.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
service: jwt-demo
provider:
name: aws
runtime: nodejs14.x
stage: ${opt:stage, 'dev'}
region: eu-north-1
memorySize: 1024
timeout: 10
logRetentionInDays: 14
versionFunctions: true
lambdaHashingVersion: 20201221
deploymentBucket:
blockPublicAccess: true
maxPreviousDeploymentArtifacts: 5
serverSideEncryption: AES256
stackTags:
Usage: ${self:service}
tags:
Usage: ${self:service}
apiGateway:
minimumCompressionSize: 1024
tracing:
apiGateway: true
lambda: true
iam:
role:
statements:
- Effect: Allow
Action:
- xray:PutTelemetryRecords
- xray:PutTraceSegments
Resource: "*"
environment:
JWKS_URI: '' # REQUIRED - Example: https://{{ID}}-{{RANDOM_ID}}.{{REGION}}.auth0.com/.well-known/jwks.json
AUDIENCE: '' # OPTIONAL - Example: https://{{RANDOM_ID}}.execute-api.{{REGION}}.amazonaws.com/dev/demo
ISSUER: '' # OPTIONAL - Example: https://{{ID}}-{{RANDOM_ID}}.{{REGION}}.auth0.com/
plugins:
- serverless-webpack
- serverless-offline
package:
individually: true
patterns:
- node_modules/aws-sdk/**
- node_modules/aws-lambda/**
functions:
Demo:
handler: src/controllers/DemoController.handler
description: Demo controller to modify
events:
- http:
path: /demo
method: POST
authorizer:
name: Authorizer
resultTtlInSeconds: 30 # See: https://forum.serverless.com/t/api-gateway-custom-authorizer-caching-problems/4695
identitySource: method.request.header.Authorization
type: token
Authorizer:
handler: src/controllers/AuthController.handler
description: ${self:service} 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'
AuthFailureExpiredGatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: EXPIRED_TOKEN
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'
AuthFailureUnauthorizedGatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'