-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
112 lines (105 loc) · 2.84 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
frameworkVersion: ">=1.2.0 <3.0.0"
service:
name: notes
publish: true
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, "dev"}
# endpointType: regional
region: ${opt:region, "eu-west-1"}
memorySize: 256
timeout: 10
environment:
TableName: ${self:custom.tableName}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:*
Resource:
- "Fn::GetAtt": [ NotesTable, Arn ]
stackTags:
REGION: ${self:provider.region}
RUNTIME: ${self:provider.runtime}
functions:
create:
name: ${self:custom.prefix}-createFn
description: Create a new Note
handler: handler.create
events:
- http:
path: notes
method: POST
cors: true
authorizer: aws_iam
get:
name: ${self:custom.prefix}-getFn
description: Get details for a Note by id
handler: handler.get
events:
- http:
path: notes/{id}
method: GET
cors: true
authorizer: aws_iam
list:
name: ${self:custom.prefix}-listFn
description: List all Notes belonging to the user
handler: handler.list
events:
- http:
path: notes
method: GET
cors: true
authorizer: aws_iam
update:
name: ${self:custom.prefix}-updateFn
description: Update a Note by id
handler: handler.update
events:
- http:
path: notes/{id}
method: PUT
cors: true
authorizer: aws_iam
delete:
name: ${self:custom.prefix}-deleteFn
description: Delete a specific Note
handler: handler.delete
events:
- http:
path: notes/{id}
method: DELETE
cors: true
authorizer: aws_iam
resources:
Description: ${self:service.name} stack
Resources:
NotesTable: ${file(resources/notes-table.yml)}
IdentityPool: ${file(resources/identity-pool.yml)}
UserPoolClient: ${file(resources/user-pool-client.yml)}
UserPool: ${file(resources/user-pool.yml)}
CognitoAuthorizedRole: ${file(resources/authorized-role.yml)}
CognitoUnAuthorizedRole: ${file(resources/unauthorized-role.yml)}
CognitoRoleMapping: ${file(resources/role-mapping.yml)}
AttachmentsBucket: ${file(resources/attachments-bucket.yml)}
Outputs: ${file(resources/outputs.yml)}
plugins:
- serverless-webpack
- serverless-stack-output
package:
individually: true
custom:
webpack:
packager: yarn
includeModules:
forceExclude:
- aws-sdk
prefix: ${self:service}-${self:provider.stage}-${sls:instanceId}
tableName: ${self:custom.prefix}-table
bucketName: ${self:custom.prefix}-attachments-bucket
userPoolName: ${self:custom.prefix}-userpool
identityPoolName: ${self:service}_${self:provider.stage}_identitypool
clientName: ${self:custom.prefix}-${file(./package.json):name}
output:
file: ./output.json