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.

  1. Access the EC2 interface:
    • Choose Auto Scaling Groups
    • Choose ASG Web Server
    • Click on Activity tab
    • Click on Create notification

ConnectPrivate

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

ConnectPrivate

  1. Access SNS interface:

ConnectPrivate

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

ConnectPrivate

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

ConnectPrivate

  1. Scroll down, choose Create subscription

ConnectPrivate

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

ConnectPrivate

  1. Click on the email, then choose Confirm subscription.

ConnectPrivate

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

ConnectPrivate

  1. You can check the status of the subscriptions.

ConnectPrivate

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

ConnectPrivate

ConnectPrivate

  1. SSH successfully.

ConnectPrivate

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

ConnectPrivate

  1. Type stress to see if the stress is installed.

ConnectPrivate

  1. 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.

ConnectPrivate

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

ConnectPrivate

ConnectPrivate

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

ConnectPrivate

  1. 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.

ConnectPrivate

  1. The Auto Scaling Group launch a new instance.

ConnectPrivate

  1. 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

ConnectPrivate

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

ConnectPrivate

ConnectPrivate

ConnectPrivate

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