This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
177 lines (168 loc) · 4.9 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
service: cognito-user-manager-backend
provider:
name: aws
stage: ${opt:stage, 'dev'}
runtime: go1.x
region: eu-central-1
role: cumbDefaultRole
memorySize: 256
package:
exclude:
- ./**
include:
- ./bin/**
functions:
authorizer:
handler: bin/authorizer
description: JWT authorizer
list-pools:
role: cumbCognitoRole
handler: bin/list-pools
description: Get all user pools
events:
- http:
path: list-pools
method: post
cors: true
authorizer: authorizer
list-users:
role: cumbCognitoRole
handler: bin/list-users
description: Get all users for a given user pool
events:
- http:
path: list-users
method: post
cors: true
authorizer: authorizer
user-enabled:
role: cumbCognitoRole
handler: bin/user-enabled
description: Toggle user enabled status inside given user pool
events:
- http:
path: users/{username}/enabled
method: post
cors: true
authorizer: authorizer
user-details:
role: cumbCognitoRole
handler: bin/user-details
description: Get user details by username for given user pool
events:
- http:
path: user-details
method: post
cors: true
authorizer: authorizer
update-user-attributes:
role: cumbCognitoRole
handler: bin/update-user-attributes
description: Update user attributes
events:
- http:
path: update-user-attributes
method: post
cors: true
authorizer: authorizer
sign-in:
handler: bin/sign-in
description: Get jwt token using username/password
events:
- http:
path: signin
method: post
cors: true
environment:
USERNAME: "admin"
PASSWORD: "secret2018"
resources:
Resources:
GatewayResponseDefault4XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
gatewayresponse.header.Access-Control-Allow-Methods: "'PUT,POST,OPTIONS'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: 'ApiGatewayRestApi'
cumbDefaultRole:
Type: AWS::IAM::Role
Properties:
RoleName: CognitoUserManagerBackendDefaultRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: CognitoUserManagerBackendDefaultPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/*:*:*'
cumbCognitoRole:
Type: AWS::IAM::Role
Properties:
RoleName: CognitoUserManagerBackendCognitoRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: CognitoUserManagerBackendCognitoPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- 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:*
Resource: "*"
Outputs:
ServiceEndpoint:
Description: URL of the service endpoint
Value:
Fn::Join:
- ""
- - "https://"
- Ref: ApiGatewayRestApi
- ".execute-api.eu-central-1."
- Ref: AWS::URLSuffix
- "/"
- ${self:provider.stage}
Export:
Name: ${self:service}:${self:provider.stage}:ServiceEndpoint