Data processing with Slack and serverless backend on AWS

Anton Klimenko
Jul 25, 2017 · 5 min read

Slack application

{
"token": "Jhj5dZrVaK7ZwHHjRyZWjbDl",
"team_id": "123",
"api_app_id": "xyz123",
"event": {
...
},
"type": "event_callback",
"authed_users": [
"AAABBBCCC"
],
"event_id": "EVENTID123",
"event_time": 1499081899
}

Serverless backend on AWS

Figure 1. Slack integration with AWS infrastructure

AWS Lambda functions

Figure 2. Slack request handling workflow

Environment variables for lambda functions

Table 1. AWS Lambda functions environment variables dependencies

Step function

{
"Comment": "Slack integration",
"StartAt": "FetchFile",
"States": {
"FetchFile": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT:function:slack-file-fetcher",
"Next": "SaveMetadata"
},
"SaveMetadata": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT:function:slack-metadata",
"End": true
}
}
}

AWS policies

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1",
"Effect": "Allow",
"Action": [
"states:StartExecution"
],
"Resource": [
"arn:aws:states:REGION:ACCOUNT:stateMachine:*"
]
},
{
"Sid": "Stmt2",
"Effect": "Allow",
"Action": [
"sns:Publish"
],
"Resource": [
"arn:aws:sns:REGION:ACCOUNT:slack-integrator"
]
},
{
"Sid": "Stmt3",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::slack-integrator/*"
]
}
]
}

Testing and code structure of lambda functions

Tools

Notes and gotchas

Conclusion

References

Anton Klimenko

Written by

Software Engineer @seekjobs and chef @CloudRecipesIO

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade