This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
91 lines (86 loc) · 2.31 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
service: smartlegal-userpool
# app and org for use with dashboard.serverless.com
app: smartlegal-userpool
org: benext
provider:
name: aws
runtime: nodejs12.x
region: ap-southeast-2
stage: ${self:custom.currentStage}
logRetentionInDays: 30
timeout: 30
custom:
defaultStage: dev
currentStage: ${opt:stage, self:custom.defaultStage}
userPoolName: smartlegal-${self:custom.currentStage}
userPoolClientName: test-user-pool-client-${self:custom.currentStage}
functions:
registeredOnly:
handler: handler.user
events:
- http:
path: /user
method: get
authorizer:
type: COGNITO_USER_POOLS
authorizerId:
Ref: ApiGatewayAuthorizer
cors:
origin: 'http://localhost:3000'
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
allowCredentials: true
guests:
handler: handler.anonymous
events:
- http:
path: /anonymous
method: get
resources:
Resources:
CognitoUserPool:
Type: "AWS::Cognito::UserPool"
Properties:
MfaConfiguration: OFF
UserPoolName: ${self:custom.userPoolName}
UsernameAttributes:
- email
Policies:
PasswordPolicy:
MinimumLength: 6
RequireLowercase: False
RequireNumbers: True
RequireSymbols: False
RequireUppercase: True
CognitoUserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
ClientName: ${self:custom.userPoolClientName}
GenerateSecret: False
UserPoolId:
Ref: CognitoUserPool
ApiGatewayAuthorizer:
DependsOn:
- ApiGatewayRestApi
Type: AWS::ApiGateway::Authorizer
Properties:
Name: cognito-authorizer
IdentitySource: method.request.header.Authorization
RestApiId:
Ref: ApiGatewayRestApi
Type: COGNITO_USER_POOLS
ProviderARNs:
- Fn::GetAtt: [CognitoUserPool, Arn]
Outputs:
CognitoUserPoolArn:
Value:
Fn::GetAtt:
- CognitoUserPool
- Arn
Export:
Name: CognitoUserPoolArn-${self:custom.currentStage}