-
Notifications
You must be signed in to change notification settings - Fork 6
/
serverless.yml
158 lines (151 loc) · 4.16 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
service:
name: serverless-appsync-offline-typescript-template
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name
plugins:
- serverless-webpack
- serverless-appsync-plugin
- serverless-dynamodb-local
- serverless-appsync-simulator
- serverless-offline
custom:
appsync-simulator:
location: ".webpack/service"
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
migrate: true
seed: true
seed:
dev:
sources:
- table: task
sources: [./migrations/tasks.json]
appSync:
name: taskboard_backend
authenticationType: AMAZON_COGNITO_USER_POOLS
userPoolConfig:
awsRegion: ap-northeast-1
userPoolId: ap-northeast-1_xxxxxxx
defaultAction: ALLOW
schema: schema.graphql
dataSources:
- type: AMAZON_DYNAMODB
name: task
description: Task table
config:
tableName: { Ref: Table }
serviceRoleArn: { Fn::GetAtt: [AppSyncDynamoDBServiceRole, Arn] }
region: ap-northeast-1
- type: AWS_LAMBDA
name: info
description: Lambda DataSource for application infomation
config:
functionName: info
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:invokeFunction"
Resource:
- "*"
mappingTemplatesLocation: mapping-templates
mappingTemplates:
- dataSource: info
type: Query
field: info
request: Query.info.request.vtl
response: Query.info.response.vtl
- type: Query
field: getTask
kind: PIPELINE
request: "start.vtl"
response: "end.vtl"
functions:
- getTask
- dataSource: task
type: Query
field: listTasks
request: "Query.listTasks.request.vtl"
response: "Query.listTasks.response.vtl"
- dataSource: task
type: Mutation
field: createTask
request: "Mutation.createTask.request.vtl"
response: "end.vtl"
- dataSource: task
type: Mutation
field: updateTask
request: "Mutation.updateTask.request.vtl"
response: "end.vtl"
- dataSource: task
type: Mutation
field: deleteTask
request: "Mutation.deleteTask.request.vtl"
response: "end.vtl"
functionConfigurations:
- dataSource: task
name: "getTask"
request: "getTask.request.vtl"
response: "getTask.response.vtl"
provider:
name: aws
runtime: nodejs12.x
apiGateway:
minimumCompressionSize: 1024 # Enable gzip compression for responses > 1 KB
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
functions:
info:
handler: handler.info
resources:
Resources:
Table:
Type: AWS::DynamoDB::Table
Properties:
TableName: task
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: status
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: status
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
AppSyncDynamoDBServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: appsync-dynamodb-role
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "appsync.amazonaws.com"
Action:
- "sts:AssumeRole"
Policies:
- PolicyName: "dynamo-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "dynamodb:Query"
- "dynamodb:BatchWriteItem"
- "dynamodb:GetItem"
- "dynamodb:DeleteItem"
- "dynamodb:PutItem"
- "dynamodb:Scan"
- "dynamodb:UpdateItem"
Resource:
- "*"