-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
178 lines (177 loc) · 5.54 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
171
172
173
174
175
176
177
178
service: slack-standup
frameworkVersion: "3"
provider:
architecture: arm64
lambdaHashingVersion: "20201221"
name: aws
runtime: nodejs18.x
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
stage: ${self:provider.stage}
PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL: debug
AWS_XRAY_CONTEXT_MISSING: "IGNORE_ERROR"
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-2'}
memorySize: 256
logRetentionInDays: 5
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource:
- !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${self:service}-${opt:stage, self:provider.stage}-*
- Effect: "Allow"
Action:
- "secretsmanager:GetSecretValue"
Resource:
Fn::Join:
- ":"
- - "arn:aws:secretsmanager"
- ${self:provider.region}
- Ref: "AWS::AccountId"
- "secret"
- "SlackStandup_Secret_*"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
Fn::Join:
- ":"
- - "arn:aws:dynamodb"
- ${self:provider.region}
- Ref: "AWS::AccountId"
- "table/*_STANDUP_STATUS"
- Effect: Allow
Action:
- dynamodb:Query
Resource:
Fn::Join:
- ":"
- - "arn:aws:dynamodb"
- ${self:provider.region}
- Ref: "AWS::AccountId"
- "table/*_STANDUP_STATUS/index/*"
resources:
Resources:
StatusDynamoDbTable:
Type: "AWS::DynamoDB::Table"
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "userId"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
- AttributeName: "userId"
KeyType: "RANGE"
GlobalSecondaryIndexes:
- IndexName: "userId-index"
KeySchema:
- AttributeName: "userId"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
TableName: ${self:provider.stage}_STANDUP_STATUS
TimeToLiveSpecification:
AttributeName: timeToLive
Enabled: true
functions:
slack:
# -- enable these two lines for provisioned concurrency --
# provisionedConcurrency: 1
# concurrencyAutoscaling: ${self:custom.lambda.concurrencyAutoscaling}
# -- enable for warmer --
# warmup:
# default:
# enabled: true
handler: src/app.handler
events:
- http:
path: slack/events
method: post
iamRoleStatementsInherit: true
layers: ${self:custom.secrets-lambda-arns.${self:custom.region}}
tracing: Active
plugins:
- serverless-express
- serverless-webpack
# -- enable for provisioned concurrency --
# - serverless-provisioned-concurrency-autoscaling
# -- enable for warmup lambda --
# - serverless-plugin-warmup
- serverless-iam-roles-per-function
- serverless-offline
package:
excludeDevDependencies: true
individually: true
custom:
region: "${opt:region, self:provider.region}"
secrets-lambda-arns:
us-east-1: arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:11
us-east-2: arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:11
us-west-1: arn:aws:lambda:us-west-1:997803712105:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:8
us-west-2: arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:11
webpack:
webpackConfig: "webpack.config.cjs"
includeModules: true
excludeFiles: src/**/*.test.js
packagerOptions:
copyPackageSectionNames:
- type
- exports
- main
# esbuild:
# # https://github.com/floydspace/serverless-esbuild/issues/483#issuecomment-1718837093
# format: esm
# outputFileExtension: .mjs
# # plugins:
# # ./src/esbuild-plugins.js
# banner:
# js: import { createRequire } from 'module';const require = (await import('node:module')).createRequire(import.meta.url);const __filename = (await import('node:url')).fileURLToPath(import.meta.url);const __dirname = (await import('node:path')).dirname(__filename);
# -- enable for provisioned concurrency --
# lambda:
# concurrencyAutoscaling:
# enabled: true
# maximum: 1
# minimum: 1
# scheduledActions:
# - name: OpenOfficeTime
# timezone: "America/Denver"
# schedule: "cron(0 5 ? * MON-FRI *)"
# action:
# maximum: 1
# minimum: 1
# - name: CloseOfficeTime
# timezone: "America/Denver"
# schedule: "cron(0 21 ? * MON-FRI *)"
# action:
# maximum: 0
# minimum: 0
# -- enable for warmup lambda --
# warmup:
# default:
# events:
# - schedule: rate(4 minutes)
# enabled:
# - prod
# concurrency: 1
# verbose: false
# memorySize: 128
# # -- fine-tuned warmup --
# # events:
# # 4-11:59 UTC is 9pm - 4:59am MST
# # - schedule: cron(0/5 4-11 ? * MON-FRI *)
# # - schedule: cron(0/5 * ? * SAT-SUN *)