-1

I am facing an issue that I have integrated a lambda function for auto starting and stopping of a EC2 instance according to my office hours. However, The issue is that EC2 is on ASG and ASG creates redundant Instance automatically. Could someone please suggest a way to schedule ASG operation to stop and start according to my requirements other than disabling the ASG or removing that instance from ASG.

Mirza
  • 33
  • 5

3 Answers3

2

You can suspend an Auto Scaling group (ASG) according to your EC2 auto-start and stop schedule by using AWS Lambda functions. Lambda functions can be used to trigger the ASG suspend and resume actions at the desired times. You can also use CloudWatch Events to trigger the Lambda functions at the desired times. More details here

Chaitanya
  • 3,590
  • 14
  • 33
0

I solved this case by using automatic Scaling and creating one schedule to shut down by putting 0s in desired, min and max capacity. And another scheduled to start by putting 1s in desired, min and max capacity(since my requirement is 1 instance at a time) I am not sure if this is the best practice but I solved my issue via this technique.

Mirza
  • 33
  • 5
0

Have you considered scheduled scaling?

To use scheduled scaling, you create scheduled actions. Scheduled actions are performed automatically as a function of date and time. When you create a scheduled action, you specify when the scaling activity should occur and the new desired, minimum, and maximum sizes for the scaling action. You can create scheduled actions that scale one time only or that scale on a recurring schedule.

Link: https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scheduled-scaling.html#create-sch-actions

tibsonk
  • 1
  • 1