-
Notifications
You must be signed in to change notification settings - Fork 48
/
serverless.yml
103 lines (98 loc) · 2.27 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
service: dynamodb-crud-api
provider:
name: aws
runtime: nodejs14.x
stage: dev
region: us-west-1
environment:
DYNAMODB_TABLE_NAME: ${self:custom.postsTableName}
custom:
postsTableName: posts-table-${self:provider.stage}
plugins:
- serverless-iam-roles-per-function
functions:
getPost:
handler: api.getPost
name: get-post
memorySize: 128 # mb
timeout: 5 # seconds
events:
- http:
path: post/{postId}
method: GET
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
Resource: !GetAtt PostsTable.Arn
createPost:
handler: api.createPost
name: create-post
memorySize: 128 # mb
timeout: 5 # seconds
events:
- http:
path: post
method: POST
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
Resource: !GetAtt PostsTable.Arn
updatePost:
handler: api.updatePost
name: update-post
memorySize: 128 # mb
timeout: 5 # seconds
events:
- http:
path: post/{postId}
method: PUT
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:UpdateItem"
Resource: !GetAtt PostsTable.Arn
deletePost:
handler: api.deletePost
name: delete-post
memorySize: 128 # mb
timeout: 5 # seconds
events:
- http:
path: post/{postId}
method: DELETE
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:DeleteItem"
Resource: !GetAtt PostsTable.Arn
getAllPosts:
handler: api.getAllPosts
name: get-all-posts
memorySize: 128 # mb
timeout: 5 # seconds
events:
- http:
path: posts
method: GET
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:Scan"
Resource: !GetAtt PostsTable.Arn
resources:
Resources:
PostsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.postsTableName}
AttributeDefinitions:
- AttributeName: postId
AttributeType: S
KeySchema:
- AttributeName: postId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1