-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
152 lines (149 loc) · 3.9 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
service: jeremie-toolkit-service
custom:
environment: ${opt:stage, 'development'}
certEnvironment:
development: "test"
staging: "test"
production: "production"
region: ${opt:region, 'eu-west-1'}
includeDependencies:
always:
- 'local/**'
documentation:
info:
...cut...
models:
-
name: "ToolkitPut"
description: "Toolkit Data Object"
contentType: "application/json"
schema: ${file(models/toolkit-put.json)}
-
name: "ToolkitPost"
description: "Toolkit Data Object"
contentType: "application/json"
schema: ${file(models/toolkit-post.json)}
provider:
name: aws
runtime: nodejs8.10
region: eu-west-1
endpointType: REGIONAL
stage: ${opt:stage, 'development'}
timeout: 15
memorySize: 512
environment:
STACK: ${self:custom.environment}
DEFAULT_REGION: ${self:custom.region}
DYNAMODB_TABLE: "toolkitt"
BUCKET_NAME: jeremie-test
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
# Restrict our IAM role permissions to
# the specific table for the stage
Resource:
- "Fn::GetAtt": [ ToolkitTable, Arn ]
package:
individually: true
excludeDevDependencies: false
exclude:
- .git/**
resources:
Resources:
ToolkitTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}
onlyBody:
Type: "AWS::ApiGateway::RequestValidator"
Properties:
Name: 'only-body'
RestApiId:
Ref: ApiGatewayRestApi
ValidateRequestBody: true
ValidateRequestParameters: false
GatewayResponseBadRequestBody:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
RestApiId:
Ref: "ApiGatewayRestApi"
ResponseType: BAD_REQUEST_BODY
ResponseTemplates:
"application/json": '{"message":"$context.error.validationErrorString", "requestId":"$context.requestId", "jeremie":"<3"}'
functions:
getItem:
handler: toolkit.getItemHandler
events:
- http:
path: toolkit/{uuid}
method: get
cors: true
request:
parameters:
paths:
uuid: true
putItem:
handler: toolkit.putItemHandler
events:
- http:
path: toolkit
method: post
cors: true
integration: lambda
request:
passThrough: NEVER
reqValidatorName: onlyBody
documentation:
summary: "Create a new toolkit"
description: "Create a new toolit"
requestModels:
"application/json": "ToolkitPost"
- http:
path: toolkit/{uuid}
method: put
cors: true
integration: lambda
request:
passThrough: NEVER
parameters:
paths:
uuid: true
reqValidatorName: onlyBody
documentation:
summary: "Create a new toolkit"
description: "Create a new toolit"
requestModels:
"application/json": "ToolkitPut"
deleteItem:
handler: toolkit.putItemHandler
events:
- http:
path: toolkit/{uuid}
method: delete
cors: true
timeout: 10
tags:
endpoint: "toolkit"
package:
include:
- toolkit.js
plugins:
- serverless-aws-documentation
- serverless-reqvalidator-plugin