-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
103 lines (98 loc) · 2.51 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-serverless-crud-api
provider:
name: aws
runtime: nodejs18.x
stage: dev
region: ap-south-1
environment:
DYNAMODB_TABLE_NAME: ${self:custom.productsTableName}
custom:
productsTableName: products-table-${self:provider.stage}
plugins:
- serverless-iam-roles-per-function
functions:
getProduct:
handler: api.getProduct
name: get-product
memorySize: 128
timeout: 5
events:
- http:
path: product/{productId}
method: GET
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
Resource: "arn:aws:dynamodb:ap-south-1:*:table/${self:custom.productsTableName}"
createProduct:
handler: api.createProduct
name: create-product
memorySize: 128
timeout: 5
events:
- http:
path: product
method: POST
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:PutItem
Resource: "arn:aws:dynamodb:ap-south-1:*:table/${self:custom.productsTableName}"
updateProduct:
handler: api.updateProduct
name: update-product
memorySize: 128
timeout: 5
events:
- http:
path: product/{productId}
method: PATCH
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:UpdateItem
Resource: "arn:aws:dynamodb:ap-south-1:*:table/${self:custom.productsTableName}"
deleteProduct:
handler: api.deleteProduct
name: delete-product
memorySize: 128
timeout: 5
events:
- http:
path: product/{productId}
method: DELETE
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:ap-south-1:*:table/${self:custom.productsTableName}"
getAllProducts:
handler: api.getAllProducts
name: get-all-products
memorySize: 128
timeout: 5
events:
- http:
path: products
method: GET
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Scan
Resource: "arn:aws:dynamodb:ap-south-1:*:table/${self:custom.productsTableName}"
resources:
Resources:
ProductsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.productsTableName}
AttributeDefinitions:
- AttributeName: productId
AttributeType: S
KeySchema:
- AttributeName: productId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1