-
Notifications
You must be signed in to change notification settings - Fork 10
/
serverless.yml
282 lines (248 loc) · 9.94 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
service: socless-slack
unresolvedVariablesNotificationMode: error
provider:
name: aws
runtime: python3.9
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}} # default token if none specified via lambda args at runtime
CACHE_USERS_TABLE:
Ref: SlackUsernamesTable
# Add Bot Tokens to the environment vars for multi-bot support.
# <BOT_NAME>_TOKEN can be used in playbooks at runtime as "token" : "{{env('TSIRT_TOKEN')}}"
# To enable interactivity, you will also need to add the bot signing secret under the
# `SlackEndpoint` lambda function below
TSIRT_TOKEN: ${{ssm:/socless/slack/bot_token~true}}
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
package:
individually: true
custom:
socless: socless-${{self:provider.stage}}
statesRole: ${{cf:socless-${{self:provider.stage}}.StatesExecutionRoleArn}}
core:
SetInvestigationStatus: ${{cf:socless-${{self:provider.stage}}.SetInvestigationStatus}}
MergeParallelOutput: ${{cf:socless-${{self:provider.stage}}.MergeParallelOutput}}
playbooks:
- socless_slack_integration_test
- socless_slack_e2e_interaction_test
slash_command: ${{ssm:/socless/slack/slash_command}}
concurrencyAmount:
dev: 1
stage: 1
prod: 3
sandbox: 1
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}}
HELP_TEXT: ${{ssm:/socless/slack_endpoint/help_text~true}}
# Add bot Signing Secret for multi-bot support.
# <BOT_NAME>_SECRET, where <BOT_NAME> is the same name passed via query params
# to the slack endpoint: <endpoint>/<stage/slack?bot=<BOT_NAME>
TSIRT_SECRET: ${{ssm:/socless/slack/signing_secret~true}}
package:
artifact: .archives/functions/_slack_endpoint.zip
provisionedConcurrency: ${{self:custom.concurrencyAmount.${{self:provider.stage}}}}
events:
- http:
path: /slack
method: post
cors: true
WebApi:
handler: lambda_function.lambda_handler
name: socless_slack_web_api_request
description: Socless Slack integration for any API call
package:
artifact: .archives/functions/web_api.zip
FindUser:
handler: lambda_function.lambda_handler
name: socless_slack_find_user
description: Socless Slack integration find a user's profile in Slack
package:
artifact: .archives/functions/find_user.zip
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:
artifact: .archives/functions/prompt_for_confirmation.zip
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:
artifact: .archives/functions/prompt_for_response.zip
SendMessage:
handler: lambda_function.lambda_handler
name: socless_slack_send_message
description: Socless Slack integration to send messages without expecting responses
package:
artifact: .archives/functions/send_message.zip
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:
artifact: .archives/functions/send_dialog.zip
# Note: when removing this provisionedConcurrency config for this function,
# be sure to also remove the `:provisioned` prefix in Outputs.SendDialog
# and re-deploy all playbooks using the output to ensure the right version
# of the lambda function is referenced
provisionedConcurrency: ${{self:custom.concurrencyAmount.${{self:provider.stage}}}}
CreateChannel:
handler: lambda_function.lambda_handler
name: socless_slack_create_channel
description: Create a slack channel
package:
artifact: .archives/functions/create_channel.zip
CheckIfUserInChannel:
handler: lambda_function.lambda_handler
name: socless_slack_check_user_in_channel
description: Check if user is in a channel
package:
artifact: .archives/functions/check_user_in_channel.zip
SetChannelTopic:
handler: lambda_function.lambda_handler
name: socless_slack_set_channel_topic
description: Set topic for a channel
package:
artifact: .archives/functions/set_channel_topic.zip
InviteToChannel:
handler: lambda_function.lambda_handler
name: socless_slack_invite_to_channel
description: invite a slack member to channel
package:
artifact: .archives/functions/invite_to_channel.zip
ListChannels:
handler: lambda_function.lambda_handler
name: socless_slack_list_channels
description: list all channels
package:
artifact: .archives/functions/list_channels.zip
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:
artifact: .archives/functions/_update_cached_users.zip
UploadFile:
handler: lambda_function.lambda_handler
name: socless_slack_upload_file
description: Socless Slack integration to send messages without expecting responses
package:
artifact: .archives/functions/upload_file.zip
resources:
- ${{file(resources/dynamodb.yml)}} # Cache usernames dynamodb table
# Uncomment this to deploy the slack test case with your code
# - 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:
WebApi:
Description:
ARN of Socless Slack generic
Value:
Fn::Sub: ${WebApiLambdaFunction.Arn}
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:
# Output the Arn for the provisionedConcurrency version of the function,
# the `:provisioned` suffix is auto-created by the
# serverless framework and carries the actual provisioned concurrency
Fn::Sub: ${SendDialogLambdaFunction.Arn}:provisioned
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}
UploadFile:
Description: ARN of Socless Slack integration to send a file
Value:
Fn::Sub: ${UploadFileLambdaFunction.Arn}