-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
83 lines (78 loc) · 1.92 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
service: sls-custom-authorizer
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name
frameworkVersion: '3'
useDotenv: true
provider:
name: aws
region: us-east-2
runtime: nodejs14.x
environment:
USER_TABLE_NAME: ${env:USER_TABLE_NAME}
APP_SECRET: ${env:APP_SECRET}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:*
Resource: '*'
custom:
fDir: src/functions/
allowAdminAuthDir: src/functions/authorizers/allowAdmin.handler
serverless-offline:
httpPort: 8080
lambdaPort: 8081
dynamodb:
stages:
- dev
start:
port: 8000
migrate: true
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-offline
functions:
createUser:
handler: ${self:custom.fDir}user/create.handler
events:
- http:
method: post
path: /create-user
cors: true
createSession:
handler: ${self:custom.fDir}session/create.handler
events:
- http:
method: post
path: /session
cors: true
findAllUsers:
handler: ${self:custom.fDir}user/findAll.handler
events:
- http:
method: get
path: /find-all-users
cors: true
authorizer: allowAdminAuthorizerFunc
allowAdminAuthorizerFunc:
handler: ${self:custom.allowAdminAuthDir}
resources:
Resources:
users:
# https://docs.aws.amazon.com/pt_br/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.USER_TABLE_NAME}
AttributeDefinitions:
- AttributeName: email
AttributeType: S
KeySchema:
- AttributeName: email
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1