-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathserverless.yml
261 lines (229 loc) · 8.26 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
service: socless-slack
unresolvedVariablesNotificationMode: error
provider:
name: aws
runtime: python3.7
variableSyntax: "\\${{([ ~:a-zA-Z0-9._\\'\",\\-\\/\\(\\)]+?)}}"
stage: ${{opt:stage}}
region: ${{opt:region}}
versionFunctions: false
memorySize: 128
timeout: 120
role: ${{cf:${{self:custom.socless}}.LambdaExecutionRoleArn}}
environment:
SOCLESS_VAULT: ${{cf:${{self:custom.socless}}.SoclessVault}}
RESULTS_TABLE: ${{cf:${{self:custom.socless}}.ExecutionResultsTable}}
SOCLESS_RESULTS_TABLE: ${{cf:${{self:custom.socless}}.ExecutionResultsTable}}
SOCLESS_MESSAGE_RESPONSE_TABLE: ${{cf:${{self:custom.socless}}.MessageResponsesTable}}
MESSAGE_RESPONSES_TABLE: ${{cf:${{self:custom.socless}}.MessageResponsesTable}}
SOCLESS_BOT_TOKEN: ${{ssm:/socless/slack/bot_token~true}}
CACHE_USERS_TABLE:
Ref: SlackUsernamesTable
vpc:
securityGroupIds:
- ${{cf:${{self:custom.socless}}.LambdaVpcSG}}
subnetIds:
- ${{cf:${{self:custom.socless}}.PrivateFunctionSubnet}}
apiGateway:
restApiId: ${{cf:${{self:custom.socless}}.APIGatewayID}}
restApiRootResourceId: ${{cf:${{self:custom.socless}}.APIGatewayRootResourceId}}
plugins:
- sls-apb
- socless_integration_packager
package:
individually: true
custom:
soclessPackager:
buildDir: build
socless: socless-${{self:provider.stage}}
core:
SetInvestigationStatus: ${{cf:socless-${{self:provider.stage}}.SetInvestigationStatus}}
MergeParallelOutput: ${{cf:socless-${{self:provider.stage}}.MergeParallelOutput}}
playbooks:
- socless_slack_integration_test
slash_command: ${{ssm:/socless/slack/slash_command}}
scheduleEnabled:
dev: true
stage: true
prod: true
sandbox: false
functions:
SlackEndpoint:
handler: lambda_function.lambda_handler
name: _socless_slack_endpoint
description: Receives messages from Slack
memorySize: 128
timeout: 30
environment:
AWAIT_MESSAGE_RESPONSE_ARN: ${{cf:${{self:custom.socless}}.AwaitMessageResponseActivity}}
SLACK_SIGNING_SECRET: ${{ssm:/socless/slack/signing_secret~true}}
HELP_TEXT: ${{ssm:/socless/slack_endpoint/help_text~true}}
package:
include:
- functions/slack_endpoint
events:
- http:
path: /slack
method: post
cors: true
- schedule:
name: SlackEndpointWarmStart_SOC
description: Triggers SlackEndpoint every 5 minutes to keep it warm
rate: cron(0/5 * * * ? *)
enabled: ${{self:custom.scheduleEnabled.${{self:provider.stage}}}}
input: {"_keepwarm": true}
FindUser:
handler: lambda_function.lambda_handler
name: socless_slack_find_user
description: Socless Slack integration find a user's profile in Slack
package:
include:
- functions/find_user
PromptForConfirmation:
handler: lambda_function.lambda_handler
name: _socless_slack_prompt_for_confirmation
description: Socless Slack integration to prompt a user for a Yes/No confirmation
environment:
SAVE_MESSAGE_RESPONSE_MACHINE: ${{cf:${{self:custom.socless}}.SaveMessageResponseTaskToken}}
package:
include:
- functions/prompt_for_confirmation
PromptForResponse:
handler: lambda_function.lambda_handler
name: _socless_slack_prompt_for_response
description: Socless Slack integration to prompt a user for a text-based response
environment:
SAVE_MESSAGE_RESPONSE_MACHINE: ${{cf:${{self:custom.socless}}.SaveMessageResponseTaskToken}}
SLACK_SLASH_COMMAND: ${{self:custom.slash_command}}
package:
include:
- functions/prompt_for_response
SendMessage:
handler: lambda_function.lambda_handler
name: socless_slack_send_message
description: Socless Slack integration to send messages without expecting responses
package:
include:
- functions/send_message
SendDialog:
handler: lambda_function.lambda_handler
name: _socless_slack_send_dialog
description: Send a dialog into Slack
environment:
SAVE_MESSAGE_RESPONSE_MACHINE: ${{cf:${{self:custom.socless}}.SaveMessageResponseTaskToken}}
package:
include:
- functions/send_dialog
events:
- schedule:
name: SendDialogWarmStart_SOC
description: Triggers SendDialog every 5 minutes to keep it warm
rate: cron(0/5 * * * ? *)
enabled: ${{self:custom.scheduleEnabled.${{self:provider.stage}}}}
input: {"_keepwarm": true}
CreateChannel:
handler: lambda_function.lambda_handler
name: socless_slack_create_channel
description: Create a slack channel
package:
include:
- functions/create_channel
CheckIfUserInChannel:
handler: lambda_function.lambda_handler
name: socless_slack_check_user_in_channel
description: Check if user is in a channel
package:
include:
- functions/check_user_in_channel
SetChannelTopic:
handler: lambda_function.lambda_handler
name: socless_slack_set_channel_topic
description: Set topic for a channel
package:
include:
- functions/set_channel_topic
InviteToChannel:
handler: lambda_function.lambda_handler
name: socless_slack_invite_to_channel
description: invite a slack member to channel
package:
include:
- functions/invite_to_channel
ListChannels:
handler: lambda_function.lambda_handler
name: socless_slack_list_channels
description: list all channels
package:
include:
- functions/list_channels
UpdateCachedUsers:
handler: lambda_function.lambda_handler
name: socless_slack_update_cached_users
description: Socless Slack integration that populates the dynamodb cache
memorySize: 192
timeout: 500
package:
include:
- functions/update_cached_users
resources:
- ${{file(resources/dynamodb.yml)}} # Cache usernames dynamodb table
- Resources:
SoclessSlackIntegrationTestcase:
Type: "AWS::SSM::Parameter"
Properties:
Description:
Fn::Sub: "Input for ${{self:service}}'s integration test playbook"
Name: /socless/slack/integration_test_input
Type: String
Value: ${{file(playbooks/socless_slack_integration_test/test_case_json.txt)}}
- Outputs:
FindUser:
Description: ARN of Socless Slack integration to find a Slack User based on
their username
Value:
Fn::Sub: ${FindUserLambdaFunction.Arn}
PromptForConfirmation:
Description: ARN of Socless Slack integration to prompt a user for a Yes/No
confirmation
Value:
Fn::Sub: ${PromptForConfirmationLambdaFunction.Arn}
PromptForResponse:
Description: ARN of Socless Slack integration to prompt a user for a text-based
response
Value:
Fn::Sub: ${PromptForResponseLambdaFunction.Arn}
SendMessage:
Description: ARN of Socless Slack integration to send messages without expecting
responses
Value:
Fn::Sub: ${SendMessageLambdaFunction.Arn}
SendDialog:
Description: ARN of Socless Slack integration for ingesting Socless integration
commands from Slack
Value:
Fn::Sub: ${SendDialogLambdaFunction.Arn}
CreateChannel:
Description: ARN of Socless Slack integration to create a channel
Value:
Fn::Sub: ${CreateChannelLambdaFunction.Arn}
CheckIfUserInChannel:
Description: ARN of Socless Slack integration to check if user is in a channel
Value:
Fn::Sub: ${CheckIfUserInChannelLambdaFunction.Arn}
SetChannelTopic:
Description: ARN of Socless Slack integration to set topic for a channel
Value:
Fn::Sub: ${SetChannelTopicLambdaFunction.Arn}
InviteToChannel:
Description: ARN of Socless Slack integration to invite a member to channel
Value:
Fn::Sub: ${InviteToChannelLambdaFunction.Arn}
ListChannels:
Description: ARN of Socless Slack integration to list all channels
Value:
Fn::Sub: ${ListChannelsLambdaFunction.Arn}
UpdateCachedUsers:
Description: ARN of Socless Slack integration that populates the dynamodb
cache
Value:
Fn::Sub: ${UpdateCachedUsersLambdaFunction.Arn}