-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Expand file tree
/
Copy pathserverless.yml
More file actions
100 lines (90 loc) · 2.19 KB
/
serverless.yml
File metadata and controls
100 lines (90 loc) · 2.19 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
88
89
90
91
92
93
94
95
96
97
98
99
100
service: serverless-http-api-dynamodb-local
frameworkVersion: "3"
plugins:
- serverless-dynamodb
- serverless-offline
custom:
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
# Uncomment if you have a DynamoDB instance already running locally you want to use instead
# noStart: true
# Create the tables according to the resources.Resources block
migrate: true
# Insert seed items on creation, configured by the custom.dynamodb.seed block
seed: true
seed:
default:
sources:
- table: ${self:provider.environment.DYNAMODB_TABLE}
sources: [./db-seeds/todos.json]
provider:
name: aws
runtime: nodejs18.x
lambdaHashingVersion: '20201221'
environment:
DYNAMODB_TABLE: ${self:service}-${sls:stage}
httpApi:
cors: true
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
functions:
create:
handler: todos/create.create
events:
- httpApi:
path: /todos
method: post
list:
handler: todos/list.list
events:
- httpApi:
path: /todos
method: get
get:
handler: todos/get.get
events:
- httpApi:
path: /todos/{id}
method: get
update:
handler: todos/update.update
events:
- httpApi:
path: /todos/{id}
method: put
delete:
handler: todos/delete.delete
events:
- httpApi:
path: /todos/{id}
method: delete
resources:
Resources:
TodosDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: ${self:provider.environment.DYNAMODB_TABLE}