-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathserverless.yml
120 lines (113 loc) · 3.5 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
service: custom-user-pool
provider:
name: aws
runtime: nodejs16.x
stage: dev
region: us-east-2
functions:
cloudFormationCustomUserPool:
handler: cloudFormationCustomUserPool.handler
role: CustomUserPoolRole
timeout: 300
postConfirmation:
handler: postConfirmation.handler
events:
- cognitoUserPool:
pool: UserPool
trigger: PostConfirmation
resources:
Resources:
CustomUserPoolRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-${self:provider.stage}-custom-user-pool-role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ${self:service}-${self:provider.stage}-custom-user-pool-policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/*:*:*'
- Effect: Allow
Action:
- cognito-idp:CreateUserPool
- cognito-idp:DeleteUserPool
- cognito-idp:UpdateUserPool
- cognito-idp:DescribeUserPool
Resource: '*'
CognitoUserPoolUserPool:
Type: "Custom::UserPool"
DependsOn: CloudFormationCustomUserPoolLambdaFunction
Properties:
ServiceToken:
Fn::GetAtt: [ "CloudFormationCustomUserPoolLambdaFunction", "Arn" ]
Region:
Ref: AWS::Region
AccountId:
Ref: AWS::AccountId
PoolProperties:
PoolName: ${self:service}-${self:provider.stage}-UserPool
MfaConfiguration: OFF
VerificationMessageTemplate:
DefaultEmailOption: "CONFIRM_WITH_CODE"
AdminCreateUserConfig:
UnusedAccountValidityDays: 7
AllowAdminCreateUserOnly: false
AutoVerifiedAttributes:
- email
Policies:
PasswordPolicy:
RequireLowercase: true
RequireSymbols: true
RequireNumbers: true
MinimumLength: 8
RequireUppercase: true
UsernameAttributes:
- email
Schema:
- Name: name
AttributeDataType: String
Mutable: true
Required: true
- Name: email
AttributeDataType: String
Mutable: false
Required: true
CognitoUserPoolClientUserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
ClientName: ${self:service}-${self:provider.stage}-UserPoolClient
UserPoolId:
Ref: CognitoUserPoolUserPool
ExplicitAuthFlows:
- ADMIN_NO_SRP_AUTH
GenerateSecret: false
RefreshTokenValidity: 30
ReadAttributes:
- name
- email
Outputs:
UserPoolId:
Value:
Ref: CognitoUserPoolUserPool
UserPoolClientId:
Value:
Ref: CognitoUserPoolClientUserPoolClient