-
Notifications
You must be signed in to change notification settings - Fork 5
/
serverless.yml
100 lines (95 loc) · 2.83 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
service: swift-sprinter-rest-api
frameworkVersion: '3'
configValidationMode: warn
package:
artifact: build/Products/Products.zip
custom:
tableName: 'products-table-${sls:stage}'
keyName: 'sku'
provider:
name: aws
region: eu-west-1
httpApi:
payload: '2.0'
cors: true
# Use provided.al2 if you build with M1, provided if you build with x86_64
runtime: provided.al2
# Use arm64 if you build with M1, or x86_64 if you build with intel
architecture: arm64
environment:
DYNAMO_DB_TABLE_NAME: '${self:custom.tableName}'
DYNAMO_DB_KEY: '${self:custom.keyName}'
iam:
role:
statements:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: "*"
- Effect: Allow
Action:
- dynamodb:UpdateItem
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:DeleteItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:DescribeTable
Resource:
- { Fn::GetAtt: [ProductsTable, Arn] }
functions:
createProduct:
handler: create
memorySize: 256
description: "[${sls:stage}] Create Product"
events:
- httpApi:
path: /products
method: post
readProduct:
handler: read
memorySize: 256
description: "[${sls:stage}] Get Product"
events:
- httpApi:
path: /products/{sku}
method: get
updateProduct:
handler: update
memorySize: 256
description: "[${sls:stage}] Update Product"
events:
- httpApi:
path: /products
method: put
deleteProduct:
handler: delete
memorySize: 256
description: "[${sls:stage}] Delete Product"
events:
- httpApi:
path: /products/{sku}
method: delete
listProducts:
handler: list
memorySize: 256
description: "[${sls:stage}] List Products"
events:
- httpApi:
path: /products
method: get
resources:
Resources:
ProductsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tableName}
AttributeDefinitions:
- AttributeName: ${self:custom.keyName}
AttributeType: S
KeySchema:
- AttributeName: ${self:custom.keyName}
KeyType: HASH
BillingMode: PAY_PER_REQUEST