generated from scaffoldly/github-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
serverless.yml
156 lines (146 loc) · 4.2 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
service: ${file(serverless.config.js):serviceName}
frameworkVersion: 2.57.0
variablesResolutionMode: '20210326'
configValidationMode: off
disabledDeprecations:
- '*'
plugins:
- serverless-bundle
- serverless-dotenv-plugin
- serverless-dynamodb-local
- serverless-plugin-resource-tagging
- serverless-offline
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: '20201221'
cfnRole: arn:${env:AWS_PARTITION, ""}:iam::${env:AWS_ACCOUNT_ID, ""}:role/${self:service}-cloudformation
stage: ${opt:stage, "local"}
logRetentionInDays: 1
apiGateway:
restApiId: ${env:AWS_REST_API_ID, "0000000000"}
restApiRootResourceId: ${env:AWS_REST_API_ROOT_RESOURCE_ID, "0000000000"}
tracing:
lambda: true
environment:
API_GATEWAY_DOMAIN: ${file(serverless.config.js):apiGatewayDomain}
STAGE_DOMAIN: ${file(serverless.config.js):stageDomain}
SERVICE_NAME: ${file(serverless.config.js):serviceName}
SERVICE_SLUG: ${file(serverless.config.js):serviceSlug}
STAGE: ${opt:stage, "local"}
stackTags:
ServiceName: ${self:service}
ServiceSlug: ${file(serverless.config.js):serviceSlug}
ServiceStage: ${opt:stage, "local"}
functions:
lambda-handler:
role: arn:${env:AWS_PARTITION, ""}:iam::${env:AWS_ACCOUNT_ID, ""}:role/${self:service}-${opt:stage, "local"}
handler: src/lambda.handler
timeout: 30
events:
- http:
path: /
method: any
- http:
path: /
method: options
- http:
path: /{proxy+}
method: any
- http:
path: /{proxy+}
method: options
resources:
Resources:
Secret:
Type: AWS::SecretsManager::Secret
Properties:
Name: lambda/${opt:stage, "local"}/${self:service}
SecretString: '{}'
Table:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${opt:stage, "local"}-${self:service}
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
GlobalSecondaryIndexes:
- IndexName: sk-pk-index
KeySchema:
- AttributeName: sk
KeyType: HASH
- AttributeName: pk
KeyType: RANGE
Projection:
ProjectionType: ALL
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
TimeToLiveSpecification:
AttributeName: expires
Enabled: true
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
SSESpecification:
SSEEnabled: true
BillingMode: PAY_PER_REQUEST
IdentityTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${opt:stage, "local"}-${self:service}-identity
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
GlobalSecondaryIndexes:
- IndexName: sk-pk-index
KeySchema:
- AttributeName: sk
KeyType: HASH
- AttributeName: pk
KeyType: RANGE
Projection:
ProjectionType: ALL
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
TimeToLiveSpecification:
AttributeName: expires
Enabled: true
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
SSESpecification:
SSEEnabled: true
BillingMode: PAY_PER_REQUEST
custom:
serverless-offline:
useChildProcesses: false
noPrependStageInUrl: true
prefix: ${file(serverless.config.js):serviceSlug}
bundle:
packager: yarn
externals:
- tsoa
copyFiles:
- from: 'public/*'
to: './'
dynamodb:
stages:
- local
start:
port: 8100
dbPath: .dynamodb
migrate: true
serverless-offline-dynamodb-streams:
endpoint: http://0.0.0.0:8100