Confiugre SNS and Auto Scaling Group
Overview
In this part, we will configure an Amazon SNS notification to notify you whenever your Auto Scaling group launches or terminates instances. Following these steps.
- Access the EC2 interface:
- Choose Auto Scaling Groups
- Choose ASG Web Server
- Click on Activity tab
- Click on Create notification

- In the Create notification interface:
- Send a notification to: Enter AutoScaling-SNS
- With these recipients: type youremail
- Click on Create

- Access SNS interface:

- Click on Topcis and chosse your Topic (AutoScaling-SNS).
- Scroll down and click on Create subscription

- In the Create subscription interface:
- Protocol: Choose Email
- Endpoint: Enter your email (This is the email that you want SNS to send notifications to)

- Scroll down, choose Create subscription

- You will receive an email from AWS in your mail box.

- Click on the email, then choose Confirm subscription.

- You will see a screen that says Subscription confirmed. Now, you have successfully confirmed your Amazozn SNS subscription.

- You can check the status of the subscriptions.

- Now, let’s SSH into one of the two EC2 instances.


- SSH successfully.

- Run the command
sudo su
to run with the root permission.

- Type
stress
to see if the stress is installed.

- Now, type
stress -c 8
. The command stress -c 8
is used to generate load on the system by running subprocesses. In this case, -c 8 means it creates 8 worker subprocesses, each of which generates load on the CPU. This helps to test the performance and stability of the system under high CPU load.

- We need to wait for 5 - 10 minutes for the Auto Scaling Group to collect Metrics.


- When CPU exceeds the 50% threshold, additional EC2 will be launched according to the scaling policy.

- Access the EC2 interface, Chọn Auto Scaling groups. Nhấn vào our Auto Scaling Groups (ASG Web Server). You will see that the Auto Scaling Group is preparing to launch a new instance.

- The Auto Scaling Group launch a new instance.

- Access Gmail and you will see an email sent from AWS. The notifications contain some following information:
- Service: AWS Auto Scaling
- EC2InstanceId: i-04ed494c64679845c
- Description: Launching a new EC2 instance: i-04ed494c64679845c
- Event: autoscaling:EC2_INSTANCE_LAUNCH

- Now, wait for 5 - 10 minutes. The Auto Scaling Group will launch a new instance.



Finally, you have learned how to configure Amazon SNS with Auto Scaling Group to notify you of important events that affect your application.