AWS - ASG with SQS

 

Today I was working on a weird request. The ask was to create an SQS notification for the ASG Instance launch. 

ASG comes with an option of SNS notification while provisioning.

But for SQS is kind of complicated.

Steps:

1) Create a launch template

2) Create an ASG.

3) Create an SQS of STANDARD type. FIFO SQS does not support notification.

4) Make sure the SQS access policy allows sending Messages.

5) Create an IAM role with assumable service to "Service": "autoscaling.amazonaws.com" and the SQS actions like "SendMessage".

6) Create a lifecycle hook via CLI. Because UI does not provide an option for notification target (SQS).

Let's create a launch template:




Let's create an ASG with the above launch template:



We are done with ASG. Will proceed with SQS.



Will proceed to create IAM role with assumable service "Service": "autoscaling.amazonaws.com" and the SQS actions like "SendMessage".


Now, Let's create a lifecycle hook with SQS.


The above will create a TEST NOTIFICATION.


Will test ASG by launching an instance.




We can see a new message in the SQS as soon as the instance is launched.













Comments

Popular posts from this blog

SRE/DevOps Syllabus

AWS Code Commit - CI/CD Series Part 1

Docker - Preventing IP overlapping