Make a Backup Bot Using AWS Lex, Lambda and Slack

Vinayak Pandey
2 min readOct 22, 2020

In this post, we’ll create a bot using Lex, Lambda, and Slack to take EC2 and RDS snapshots.

Step 1: Create a role for Lambda. For simplicity's sake, we’ll give the Administrator permission to this function so that we can use it across different functions.

Note: All the lambda functions that we’ll create, will use Python 3.6 as runtime and the role we created in step 1.

Step 2: Create a lambda function named ec2_validation and set the handler as validate.

For this function, use code given at

Step 3: Create a lambda function named ec2_fulfilment with code given at

Set fulfilment_handler as the handler.

Step 4: Create a lambda function named rds_validation with code given at

Step 5: Create a lambda function named rds_fulfilment with code given at

Step 6: Now go to the Lex console and create a bot by importing the JSON file given at You need to change your Lambda functions’ ARN in this file before you import it.

Edit: You need to grant Lex permission to invoke lambda.

 aws lambda add-permission --function-name ec2_validation --statement-id chatbot-fulfillment --action "lambda:InvokeFunction" --principal ""
aws lambda add-permission --function-name ec2_fulfilment--statement-id chatbot-fulfillment --action "lambda:InvokeFunction" --principal ""
aws lambda add-permission --function-name rds_validation --statement-id chatbot-fulfillment --action "lambda:InvokeFunction" --principal ""
aws lambda add-permission --function-name rds_fulfilment--statement-id chatbot-fulfillment --action "lambda:InvokeFunction" --principal ""

Now we are all set from the AWS side. We have a bot named backupBot which can take EC2 and RDS snapshots. You can test the bot from the Lex console.

Step 7: Launch 1 EC2 instance in us-east-1 with 2 volumes. We’ll use our bot to create a snapshot of these volumes

Step 8: Follow Step2 to Step6 given at to create a Slack application that integrates with our Lex bot. The instructions given here are pretty straightforward so I am not going to elaborate on them.

Once you are done with the integration, you’ll see your app in the Slack console. Let’s test it out.

Now go to AWS console and you should see your volume snapshot got created.