Lambda function to launch a new instanceīelow is a simple code in python for the lambda function and you can modify it according to your use case. SNS topic is useful if you want to send alerts in Slack channel like if you would like to be notified if a new EC2 instance is launched or if S3 bucket has some activity and all this can be done using the cloudwatch events and SNS but that is a topic for another day.ī. You can choose not to configure SNS as we do not require it at the moment. In step 9 while defining IAM permissions, please ensure to add these permissions in the Policy Templates" which includes - **Read-only command permissions, Lambda-invoke command permissions, Notification permissions otherwise the invocation of lambda from Slack will not work.ī. This is a pretty straightforward process and AWS Documentation to Setup Chat Clients covers it completely so I will not be providing the steps explicitly here.Ī. Configure Slack as a client in AWS Chatbot I will list the steps below to integrate slack and use the lambda function to trigger launch of EC2 instance:Ī. You can make modifications/additions to this code or even write a totally different code that satisfies your use case and then run it in slack as explained below. To achieve this, I have created a lambda function which will then be executed from Slack and it is a very simple python code just to show you how you would be launching an instance from Slack. Through this post, I would like to, if you have not already known, introduce how you can use AWS Chatbot for a very simple operation to launch an EC2 instance. Thus, I came across this AWS service called AWS Chatbot which can integrate with Slack and you can then use AWS commands on slack to trigger the API calls on AWS. Few days back I had this thought in my mind that it will be so cool if I can do some small AWS operations from the chat window rather than having to log into any of my instance or AWS console.
0 Comments
Leave a Reply. |