-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
103 lines (95 loc) · 2.73 KB
/
serverless.yml
File metadata and controls
103 lines (95 loc) · 2.73 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
101
102
103
# serverless.yml
service: customer
plugins:
- serverless-plugin-scripts
- serverless-webpack
- serverless-offline
provider:
name: aws
runtime: nodejs6.10
stage: ${self:custom.serverlessStage}
region: ${self:custom.serverlessRegion}
timeout: 30
memorySize: 256
apiKeys:
- ${self:custom.serverlessNamespace}-key
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:Query
- dynamodb:UpdateItem
- dynamodb:Scan
- dynamodb:DeleteItem
Resource:
- Fn::Join: ['',[Fn::GetAtt: DynamoDbCustomerTable.Arn, '*']]
package:
individually: true
functions:
api:
handler: src/api.handler
events:
- http:
method: any
path: /{proxy+}
private: true
cors: true
- http:
method: any
path: /
private: true
cors: true
environment:
DYNAMODB_CUSTOMER_TABLENAME: ${self:custom.dynamoDbCustomerTableName}
api-docs:
handler: src/api-docs.handler
events:
- http: get /docs
- http: get /docs/{proxy+}
custom:
webpackIncludeModules: true
serverlessRegion: ${opt:region, 'ap-southeast-2'}
serverlessStage: ${opt:stage, 'tst'}
serverlessNamespace: ${self:service}-${self:custom.serverlessStage}
apiGatewayEnpoint: ${self:custom.apiGatewayMapping.${self:custom.serverlessStage}}
apiGatewayMapping:
tst: tst
stg: stg
prd: prod
dynamoDbCustomerTableName: ${self:custom.serverlessNamespace}-customers-dyn
dynamoDbCustomerReadCapacity: ${opt:dynamodb-customer-read-capacity, '1'}
dynamoDbCustomerWriteCapacity: ${opt:dynamodb-customer-write-capacity, '1'}
resources:
Resources:
ApiGatewayRestApi:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Name: ${self:custom.serverlessNamespace}
ApiGatewayMapping:
Type: 'AWS::ApiGateway::BasePathMapping'
DependsOn: ApiGatewayApiKey1
Properties:
BasePath: ${self:service}
DomainName: ${self:custom.apiGatewayEnpoint}
RestApiId:
Ref: ApiGatewayRestApi
Stage: ${self:custom.serverlessStage}
DynamoDbCustomerTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: ${self:custom.dynamoDbCustomerTableName}
KeySchema:
- AttributeName: id
KeyType: HASH
AttributeDefinitions:
- AttributeName: id
AttributeType: S
ProvisionedThroughput:
ReadCapacityUnits: ${self:custom.dynamoDbCustomerReadCapacity}
WriteCapacityUnits: ${self:custom.dynamoDbCustomerWriteCapacity}
Outputs:
ApiGatewayApiKeyId:
Description: The default API Key ID
Value:
Ref: ApiGatewayApiKey1