-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
88 lines (82 loc) · 1.96 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
service: sls-todos
# 実行環境に関する設定
provider:
name: aws
runtime: nodejs6.10
region: ap-northeast-1
role: ${DYNAMO_ACCESS_ROLE} # dynamoにアクセス可能なロール。環境変数に入っている想定
# 利用するプラグインについて
plugins:
- serverless-offline
- serverless-dynamodb-local
- serverless-plugin-include-dependencies
# デプロイ時のパッケージの内容について
package:
include:
- src/**
# lambdaを実行するトリガの設定。今回はAPI Gatewayのルーティング設定
functions:
sls-todo:
handler: src/routes/index.handler
events:
- http:
path: /todos
method: get
cors: true
- http:
path: /todo
method: post
cors: true
- http:
path: /todo/{id}
method: get
cors: true
request:
parameters:
paths:
id: true
- http:
path: /todo/{id}
method: put
cors: true
request:
parameters:
paths:
id: true
- http:
path: /todo/{id}
method: delete
cors: true
request:
parameters:
paths:
id: true
# ローカルのdynamodbの起動設定
custom:
dynamodb:
start:
port: 8888
inMemory: true
migrate: true
seed: true
seed:
test:
sources:
- table: sls-todos
sources: [./seeds/todo-items.json]
# CloudFormationの形式でのリソース定義
resources:
Resources:
slsTodos:
Type: AWS::DynamoDB::Table
Properties:
TableName: sls-todos
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1