-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
90 lines (83 loc) · 2.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
org: YOUR_ORG
app: serverless-auth-api
service: serverless-auth-api
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
deploymentBucket:
name: YOUR_S3_BUCKET_NAME
environment:
JWT_KEY: YOUR_JWT_KEY_HERE
DYNAMODB_USERS_TABLE: ${self:service}-users-${sls:stage}
DYNAMODB_TOKENS_TABLE: ${self:service}-tokens-${sls:stage}
DYNAMODB_CARS_TABLE: ${self:service}-cars-${sls:stage}
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:Get*"
- "dynamodb:Scan*"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
Resource: arn:aws:dynamodb:${aws:region}:${aws:accountId}:table/${self:service}-users-${sls:stage}
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:Get*"
- "dynamodb:Scan*"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:Get*"
- "dynamodb:Scan*"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
Resource: arn:aws:dynamodb:${aws:region}:${aws:accountId}:table/${self:service}-cars-${sls:stage}
httpApi:
authorizers:
tokenAuthorizer:
functionName: authorizer
type: request
identitySource: $request.header.Authorization
enableSimpleResponses: true
functions:
- ${file(./serverless-yml-functions/auth.yml)}
- ${file(./serverless-yml-functions/cars.yml)}
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: email
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: email
KeyType: HASH
TableName: ${self:service}-users-${sls:stage}
TokensTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: token
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: token
KeyType: HASH
TableName: ${self:service}-tokens-${sls:stage}
CarsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
TableName: ${self:service}-cars-${sls:stage}