0
votes

I configured for my AWS account the new AWS instance scheduler https://aws.amazon.com/answers/infrastructure-management/instance-scheduler/

The problem seems that, tagging ec2-instances through a scaling group the ec2-instances are correctly stopped, but since my scaling group has Min number set to 2 AWS scaling group restarts them anyway.

I would not like to set Min number to 0, just because is useful during application redeploy.

How to make the 2 services work fine?

2
Instance scheduler is for cost savings. You shutdown your instances when it is not needed. If configuration of your EC2 instances is automated, you should look at scaling down your Auto Scaling Groups. Instead of using instance scheduler, ASG supports scheduled actions. That will take care of changing the ASG capacity. However, if the instance configuration is not automated, you should leave the ASG alone.krishna_mee2004

2 Answers

1
votes

When you stop your EC2 instances that are controlled by Auto Scaling, then Auto Scaling will see them as "unhealthy" and it will proceed to terminate and replace them.

You have 2 options.

Option 1: Pause Auto Scaling processing while your EC2 instances are stopped. By doing this, Auto Scaling won't care that your EC2 instances are stopped and won't terminate them. Just remember to resume processing after you restart your EC2 instances.

However, AWS Instance Scheduler will not manage this for you, so you'll need to find another way to schedule your EC2 instances to stop & restart.

Option 2: Scale your Auto Scaling group to 0 and back to 2. This will result in terminating your EC2 instances (when you don't need them) and re-creating them (when you want them). This will only work if your EC2 instances are ephemeral.

Again, AWS Instance Scheduler will not manage this for you. Auto Scaling scheduled actions may be able to help you with this.

0
votes

Another option is to use asg standby feature before and after the aws instance scheduler. This will also let you work on the same Ami before the shutdown.

So high level solution is below:

  1. Define ec2 instance schedule using aws instance scheduler
  2. Define lambda that fetch the shutdown schedule and put the ec2 in standby mode before the planned shutdown.
  3. Define lambda that fetch the startup schedule and put the ec2 instance out of standby after the ec2 planned restart.