-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
87 lines (83 loc) · 2.47 KB
/
serverless.yml
File metadata and controls
87 lines (83 loc) · 2.47 KB
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
service: vt-sls-api
custom:
settings:
ORGS_TABLE: orgs-table
provider:
name: aws
runtime: nodejs12.x
environment: ${self:custom.settings} #self refers to the file itself (so we're saying get the settings for the environment from this file itself)
region: eu-west-1 #ireland
iamRoleStatements:
- Effect: 'Allow'
Action:
- dynamodb:DescribeTable #to know metadata about the table
- dynamodb:Scan #gets multiple items (like a get req)
- dynamodb:GetItem #gets one item
- dynamodb:PutItem #adds one item
- dynamodb:UpdateItem #like a patch req
- dynamodb:DeleteItem #deletes
Resource:
'arn:aws:dynamodb:${self:provider.region}:*:table/${self:custom.settings.ORGS_TABLE}'
#arn = amazon resource name, then specify dynamodb, then use self to point to region in file, then use self again to point to the table declared earlier in this file
functions:
createOrg: #post request
handler: handler.createOrg
events:
- http:
path: /orgs
method: post
cors: true
getAllOrgs: #get request that gets all orgs
handler: handler.getAllOrgs
events:
- http:
path: /orgs
method: get
cors: true
getOrg: #gets org by id
handler: handler.getOrg
events:
- http:
path: /orgs/{id}
method: get
cors: true
updateOrg: #updates whole org by id (put req)
handler: handler.updateOrg
events:
- http:
path: /orgs/{id}
method: put
cors: true
updateOrgAttribute: #updates single attribute of org by id (put req)
handler: handler.updateOrgAttribute
events:
- http:
path: /orgs/singleupdate/{id}
method: put
cors: true
deleteOrg: #delete org by id
handler: handler.deleteOrg
events:
- http:
path: /orgs/{id}
method: delete
cors: true
resources:
Resources:
OrgTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: 'id'
AttributeType: 'S'
KeySchema:
- AttributeName: 'id'
KeyType: 'HASH'
ProvisionedThroughput: #gives it units to read/write (how AWS tracks and charges)
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.settings.ORGS_TABLE}
#
# ------------------
# For full config options, check the docs:
# docs.serverless.com