-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
127 lines (120 loc) · 3.15 KB
/
template.yaml
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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
incident-senpai
Parameters:
SlackBotToken:
Type: String
Description: Your Slack Bot Token
SlackSigningSecret:
Type: String
Description: Your Slack Signing Secret
Architecture:
Type: String
Description: Lambda Runtime Architecture
Default: x86_64
AllowedValues:
- x86_64
- arm64
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Runtime: nodejs18.x
Architectures:
- !Ref Architecture
Layers:
- !Ref ConfigLayer
Environment:
Variables:
SLACK_BOT_TOKEN: !Ref SlackBotToken
SLACK_SIGNING_SECRET: !Ref SlackSigningSecret
Resources:
BotFunction:
Type: AWS::Serverless::Function
Properties:
MemorySize: 256
Timeout: 3
CodeUri: bot-function/
Handler: app.lambdaHandler
FunctionUrlConfig:
AuthType: NONE
Environment:
Variables:
ASYNC_TASK_QUEUE_URL: !GetAtt AsyncTaskQueue.QueueUrl
Role: !GetAtt BotFunctionRole.Arn
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: "es2020"
Sourcemap: false
EntryPoints:
- app.ts
BotFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "sts:AssumeRole"
Principal:
Service: lambda.amazonaws.com
Policies:
- PolicyName: "incident-senpai-bot-function-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- sqs:SendMessage
Resource: !GetAtt AsyncTaskQueue.Arn
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AsyncFunction:
Type: AWS::Serverless::Function
Properties:
MemorySize: 128
Timeout: 30
CodeUri: async-function/
Handler: app.lambdaHandler
Events:
AsyncEvent:
Type: SQS
Properties:
Queue: !GetAtt AsyncTaskQueue.Arn
BatchSize: 10
Enabled: true
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: "es2020"
Sourcemap: false
EntryPoints:
- app.ts
AsyncTaskQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: incident-senpai-async-task-queue
ConfigLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: incident-senpai-config
Description: incident-senpai config layer
ContentUri: layers/
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- nodejs18.x
RetentionPolicy: Retain
Metadata:
BuildMethod: makefile
Outputs:
BotFunction:
Description: "Lambda Function ARN"
Value: !GetAtt BotFunction.Arn
BotFunctionUrl:
Description: "Lambda Function URL"
Value: !GetAtt BotFunctionUrl.FunctionUrl