-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
182 lines (175 loc) · 4.44 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
service: food-science-api
frameworkVersion: '3'
useDotenv: true
provider:
name: aws
runtime: nodejs14.x
environment:
USER_POOL_ID: { Ref: UserPool }
CLIENT_ID: { Ref: UserClient }
RECIPES_TABLE_NAME: ${self:resources.Resources.RecipesTable.Properties.TableName}
README_FILEPATH: ${env:README_FILEPATH}
RECIPES_DIRECTORY: ${env:RECIPES_DIRECTORY}
GITHUB_BRANCH: ${env:GITHUB_BRANCH}
iamRoleStatements:
- Effect: Allow
Action:
- cognito-idp:AdminInitiateAuth
- cognito-idp:AdminCreateUser
- cognito-idp:AdminSetUserPassword
Resource: '*'
- Effect: Allow
Action:
- dynamodb:*
Resource: '*'
functions:
loginUser:
handler: handlers/users/login.handler
events:
- http:
path: login
method: post
cors: true
resetPassword:
handler: handlers/users/reset-password.handler
events:
- http:
path: reset-password
method: post
cors: true
createUser:
handler: handlers/users/create.handler
events:
- http:
path: users
method: post
cors: true
authorizer:
name: PrivateAuthorizer
type: COGNITO_USER_POOLS
arn:
Fn::GetAtt:
- UserPool
- Arn
claims:
- email
- name
createRecipe:
handler: handlers/recipes/create.handler
environment:
GITHUB_USER: ${env:GITHUB_USER}
GITHUB_TOKEN: ${env:GITHUB_TOKEN}
GITHUB_REPO: ${env:GITHUB_REPO}
events:
- http:
path: recipes
method: post
cors: true
authorizer:
name: PrivateAuthorizer
type: COGNITO_USER_POOLS
arn:
Fn::GetAtt:
- UserPool
- Arn
claims:
- email
- name
readManyRecipes:
handler: handlers/recipes/readMany.handler
events:
- http:
path: recipes
method: get
cors: true
authorizer:
name: PrivateAuthorizer
type: COGNITO_USER_POOLS
arn:
Fn::GetAtt:
- UserPool
- Arn
claims:
- email
- name
readOneRecipe:
handler: handlers/recipes/readOne.handler
events:
- http:
path: recipes/{uuid}
method: get
cors: true
authorizer:
name: PrivateAuthorizer
type: COGNITO_USER_POOLS
arn:
Fn::GetAtt:
- UserPool
- Arn
claims:
- email
- name
updateRecipe:
handler: handlers/recipes/update.handler
environment:
GITHUB_USER: ${env:GITHUB_USER}
GITHUB_TOKEN: ${env:GITHUB_TOKEN}
GITHUB_REPO: ${env:GITHUB_REPO}
events:
- http:
path: recipes/{uuid}
method: patch
cors: true
authorizer:
name: PrivateAuthorizer
type: COGNITO_USER_POOLS
arn:
Fn::GetAtt:
- UserPool
- Arn
claims:
- email
- name
resources:
Resources:
UserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: serverless-auth-pool
UsernameAttributes: ["email"]
Schema:
- Name: email
Required: true
Mutable: true
- Name: name
Required: true
Mutable: false
Policies:
PasswordPolicy:
MinimumLength: 6
AutoVerifiedAttributes: ["email"]
UserClient:
Type: AWS::Cognito::UserPoolClient
Properties:
ClientName: user-pool-ui
GenerateSecret: false
UserPoolId: { Ref: UserPool }
AccessTokenValidity: 5
IdTokenValidity: 5
ExplicitAuthFlows:
- "ADMIN_NO_SRP_AUTH"
RecipesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-${opt:stage, 'development'}-recipes
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
- AttributeName: createdDate
AttributeType: N
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: uuid
KeyType: HASH
- AttributeName: createdDate
KeyType: RANGE