-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathserverless.yml
170 lines (164 loc) · 5.69 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
159
160
161
162
163
164
165
166
167
168
169
170
service: dorametrix
provider:
name: aws
runtime: nodejs20.x
architecture: arm64
stage: ${opt:stage, 'prod'}
region: ${opt:region, 'eu-north-1'}
memorySize: ${opt:memory, 1024}
timeout: ${opt:timeout, 10}
logRetentionInDays: ${param:logRetentionInDays, 7}
versionFunctions: false
httpApi:
cors: true
#disableDefaultEndpoint: true
authorizers:
AuthorizerAdd:
functionName: AuthorizerAdd
resultTtlInSeconds: ${self:custom.config.aws.apiGatewayCachingTtl.${self:provider.stage}, '0'}
identitySource:
- $request.querystring.authorization
type: request
enableSimpleResponses: true
AuthorizerGet:
functionName: AuthorizerGet
resultTtlInSeconds: ${self:custom.config.aws.apiGatewayCachingTtl.${self:provider.stage}, '0'}
identitySource:
- $request.header.Authorization
type: request
enableSimpleResponses: true
deploymentBucket:
blockPublicAccess: true
maxPreviousDeploymentArtifacts: 5
serverSideEncryption: AES256
stackTags:
Usage: ${self:service}
tags:
Usage: ${self:service}
apiGateway:
minimumCompressionSize: 1024
plugins:
- serverless-esbuild
- serverless-offline
- serverless-iam-roles-per-function
package:
individually: true
custom:
config:
apiKey: ${param:apiKey, '82490d5a-1950-4527-ab2f-5c984c861462'} # Add your desired valid API key here or use the default
awsAccountNumber: ${param:awsAccountNumber, '123412341234'} # Set this to your value if you want to use a fallback value
maxDateRange: ${param:maxDateRange, '30'}
maxLifeInDays: ${param:maxLifeInDays, '90'}
tableName: ${self:service}-${self:provider.stage}
shortcut:
shortcutApiToken: ${param:shortcutApiToken, ''} # Set this to your value if you want to use a fallback value
shortcutIncidentLabelId: ${param:shortcutIncidentLabelId, '0'} # Set this to your value if you want to use a fallback value
shortcutRepoName: ${param:shortcutRepoName, 'unknown'}
aws:
databaseArn: arn:aws:dynamodb:${aws:region}:${self:custom.config.awsAccountNumber}:table/${self:custom.config.tableName}
apiGatewayCachingTtl:
prod: 30
dev: 0
test: 0
apiGatewayCachingTtlValue: ${self:custom.aws.apiGatewayCachingTtl.${self:provider.stage}, self:custom.aws.apiGatewayCachingTtl.test} # See: https://forum.serverless.com/t/api-gateway-custom-authorizer-caching-problems/4695
esbuild:
bundle: true
minify: true
functions:
AuthorizerAdd:
handler: src/infrastructure/authorizers/Authorizer.handler
description: ${self:service} authorizer for adding metrics
environment:
API_KEY: ${self:custom.config.apiKey}
AuthorizerGet:
handler: src/infrastructure/authorizers/Authorizer.handler
description: ${self:service} authorizer for getting metrics
environment:
API_KEY: ${self:custom.config.apiKey}
AddEvent:
handler: src/infrastructure/adapters/web/AddEvent.handler
description: Report new event (this will then be automatically also created as a change, deployment, or incident)
events:
- httpApi:
method: POST
path: /event
authorizer:
name: AuthorizerAdd
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:PutItem
- dynamodb:Query
Resource: ${self:custom.aws.databaseArn}
environment:
REGION: ${aws:region}
TABLE_NAME: ${self:custom.config.tableName}
MAX_DATE_RANGE: ${self:custom.config.maxDateRange}
MAX_LIFE_IN_DAYS: ${self:custom.config.maxLifeInDays}
SHORTCUT_TOKEN: ${self:custom.config.shortcut.shortcutApiToken}
SHORTCUT_INCIDENT_LABEL_ID: ${self:custom.config.shortcut.shortcutIncidentLabelId}
SHORTCUT_REPONAME: ${self:custom.config.shortcut.shortcutRepoName}
GetMetrics:
handler: src/infrastructure/adapters/web/GetMetrics.handler
description: Get DORA metrics
events:
- httpApi:
method: GET
path: /metrics
authorizer:
name: AuthorizerGet
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:PutItem
- dynamodb:Query
Resource: ${self:custom.aws.databaseArn}
environment:
REGION: ${aws:region}
TABLE_NAME: ${self:custom.config.tableName}
MAX_DATE_RANGE: ${self:custom.config.maxDateRange}
GetLastDeployment:
handler: src/infrastructure/adapters/web/GetLastDeployment.handler
description: Get the commit ID of the last production deployment
events:
- httpApi:
method: GET
path: /lastdeployment
authorizer:
name: AuthorizerGet
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:Query
Resource: ${self:custom.aws.databaseArn}
environment:
REGION: ${aws:region}
TABLE_NAME: ${self:custom.config.tableName}
MAX_DATE_RANGE: ${self:custom.config.maxDateRange}
resources:
Resources:
# DynamoDB
DorametrixTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
TableName: ${self:custom.config.tableName}
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
TimeToLiveSpecification:
AttributeName: expiresAt
Enabled: true
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
BillingMode: PAY_PER_REQUEST
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true