Scheduling Instances In ASG (Without Termination)

Instances in an Auto Scaling Group when parked in a schedule get terminated. If you want to preserve the instance, and only want to stop them, try this workflow.

  1. Create a new schedule, and set the time for when you want the resources parked

2. Now we will access both Auto Scaling Groups and the Instances launched by it

  • Choose Auto Scaling as the Service and Auto Scaling Groups as Resource

  • Choose Instances in Add-Ons

3. Now we will filter out only the ASGs that have the tag Schedule set as True, and the Instances that have state as Running

  • Choose the main output of the Resource Node from the drop-down

  • Set filter type to Tag. Select condition as Has, Key as Schedule and Value as True.

  • Click Add Condition (AND type). Set filter type to Param. Set Key as '$.addOns.Instances.data..State..Name', Operator as '==' and Value as 'running'.

4. During parking, will suspend all processes from the ASG, and then stop all the Instances launched by it.

  • For the first action, choose the main output of the the Filter Node from the drop-down. Choose Auto Scaling as the service and Suspend Processes as the action. In the params mapping editor, paste this under optional params: "ScalingProcesses": []. Click Save.

  • Add another action for parking. Choose the add-on output of the Filter Node from the drop-down. Select EC2 as Service and Stop Instances as Action. Click Save.

5. During un-parking, we will restart all the instances, and then resume all ASG processes

  • For the first action, choose the add-on output of the Filter Node from the drop-down. Choose EC2 as the service and Start Instances as the action. Click Save.

  • Add another action for un-parking. Choose the main output of the Filter Node from the drop-down. Choose Auto Scaling as the service and Resume Processes as the action. In the params mapping editor, paste this under optional params: "ScalingProcesses": []. Click Save.

6. Save the schedule. Choose Save and Deploy if you want it active from now.