- Create a Slack WorkSpace
- Create a channel where you'd like the messages to be sent
- Create a Slack App. Then inside the app:
- Create a bot user
- Give the app permissions to send messages
- Install the app in your workspace
- Record the
Bot User OAuth Access Token
- Create an S3 bucket which will be used to store your Lambda.
- Zip & upload the Lambda:
cd code
pip3 install -r requirements.txt --target ./package
cd package
zip -r9 ../ds-slack.zip .
cd ..
zip -g ds-slack.zip ds-slack.py
aws s3 cp ds-slack.zip s3://<LAMBDA_BUCKET_NAME>/<S3_KEY_PATH>/ds-slack.zip
- (Optional) Validate the template:
cd ../cfn
aws cloudformation validate-template --template-body file://cfn.yaml
- Run the template:
aws cloudformation create-stack \
--stack-name ds-slack-lambda \
--template-body file://cfn.yaml \
--parameters \
ParameterKey=LambdaBucketName,ParameterValue=<BUCKET_NAME> \
ParameterKey=LambdaS3KeyPath,ParameterValue=<S3_KEY_PATH> \
ParameterKey=SlackChannelName,ParameterValue=<SLACK_CHANNEL_NAME> \
ParameterKey=SlackApiToken,ParameterValue=<BOT_TOKEN> \
--capabilities CAPABILITY_IAM
- Configure Deep Security to send SNS notifications.
If you update the code, you'll need to update Lambda:
aws lambda update-function-code \
--function-name ds-slack \
--s3-bucket <BUCKET_NAME> \
--s3-key <S3_KEY_PATH>/ds-slack.zip