EC2AutoScaling

EC2 Autoscaling group with CloudWatch Alarms

Creation Date: October 21, 2023
Created By: Yeison Giraldo

đź’» This will Assume that you already have an EC2 Instance running and we will use that instance to create the autoscaling group

1. Click on Instances (running)…

Click on Instances (running)…

2. Check on your instance

Check on your instance

3. Click on Actions

Click on Actions

4. Click on Instance settings

Click on Instance settings

5. Click on Attach to Auto Scaling Group

Click on Attach to Auto Scaling Group

6. Type "Demo-ASG"

Type "Demo-ASG"

7. Click on Attach

Click on Attach

8. Click on Auto Scaling Groups

Click on Auto Scaling Groups

9. Check on a previous ASG or Create a new one

Check on a previous ASG or Create a new one

10. Click on Edit

Click on Edit

11. Configure group size and click update

Configure group size and click update

12. Click on Automatic scaling

Click on Automatic scaling

13. Click on Create dynamic scaling policy to add EC2 to the group

Click on Create dynamic scaling policy to add EC2 to the group

14. Select the settings and click create

Select the settings and click create

15. Click on Create dynamic scaling policy

This time we are going to configure when to remove EC2 from ASG

Click on Create dynamic scaling policy

16. Click on highlight

Click on highlight

17. Click on Create a CloudWatch alarm 

Now we need to create a cloud watch alarm so that it will trigger the autoscaling group

Click on Create a CloudWatch alarm 

18. Click on Select metric

Click on Select metric

19. Type "demo"

Type "demo"

20. Click on EC2 > By Auto Scaling Group

Click on EC2 > By Auto Scaling Group

21. Click on Select metric

Click on Select metric

22. Type "50"

Type "50"

23. Click on Whenever CPUUtilization is...

Click on Whenever CPUUtilization is...

24. Click on 5 minutes

Click on 5 minutes

25. Click on 1 minute…

Click on 1 minute…

26. Click on Next

Click on Next

27. Click on Remove

Click on Remove

28. Click on Next

Click on Next

29. Click on Next

Click on Next

30. Click on Create alarm

Click on Create alarm

31. Go back to the policy and Click on CloudWatch alarm

Go back to the policy and Click on CloudWatch alarm

32. Click on Refresh CloudWatch alarm

Click on Refresh CloudWatch alarm

33. Click on Scaling Alarm…

Click on Scaling Alarm…

34. Click on Add

Click on Add

35. Click on Remove…

Click on Remove…

36. Type "1"

Type "1"

37. Click on Create

Click on Create

38. Click on Demo Step Scaling…

Click on Demo Step Scaling…

39. Click on EC2 Dashboard

Click on EC2 Dashboard

40. Click on Instances (running)…

Click on Instances (running)…

41. Check on

Check on

42. Click on Security

Click on Security

43. Drag highlighted link

Drag highlighted link

44. Click on Security details

Click on Security details

45. Click on Security

Click on Security

46. Click on Modify IAM role

Click on Modify IAM role

47. Click on Choose IAM role

Click on Choose IAM role

48. Click on SessionManager…

Click on SessionManager…

49. Click on Update IAM role

Click on Update IAM role

50. Click on i-01af1e2720632d3ad

Click on i-01af1e2720632d3ad

51. Click on Connect

Click on Connect

52. Click on Connect

Click on Connect

53. Connect to one of the EC2 instances to run a stress test to activate the ASG

Connect to one of the EC2 instances to run a stress test to activate the ASG

54. Click on highlight

Click on highlight

55. Click on Auto Scaling Groups

Click on Auto Scaling Groups

56. Check on

Check on

57. Click on Activity

Click on Activity

58. Click on Status…

Click on Status…

59. Click on Instances

Click on Instances

60. Click on i-01af1e2720632d3ad

Click on i-01af1e2720632d3ad

61. Click on Monitoring

Click on Monitoring

62. Click on 0…

Click on 0…

63. Click on Status…

Click on Status…

64. Click on Instances

Click on Instances

65. Click on Instances

Click on Instances

66. Click on Refresh instances

Click on Refresh instances

67. Click on Auto Scaling Groups

Click on Auto Scaling Groups

68. Click on Demo-ASG

Click on Demo-ASG

69. Click on Activity

Click on Activity

70. Click on Status…

Click on Status…

# Congratulation

You have setup and Autoscaling Group using CloudWatch alarms to add and remove instances automatically.