'Application not coming up in stopping and restarting EC2 instance under ASG
I have a requirement where I need to stop EC2 instance in non-working hours.My EC2 instances are under ASG. For this, I have written an python script and followed below steps:
Get the ASG name from boto3:
describe_auto_scaling_groups
Then Suspend ASG :
asg_client.suspend_processes(AutoScalingGroupName=asg['AutoScalingGroupName'], ScalingProcesses=['Launch', 'Terminate', 'AZRebalance', 'ReplaceUnhealthy', 'HealthCheck'])
Stopping the EC2 instances under ASG by following command:
ec2_client.stop_instances()
Then restarting the server again after Non - business hours following below steps:
Get ASG name using below:
describe_auto_scaling_groups
Start the EC2 instances under this ASG using below:
ec2_client.start_instances()
Resume ASG:
asg_client.resume_processes(AutoScalingGroupName=asg['AutoScalingGroupName'])
But after restarting the EC2 instances, application inside the instance in not coming up automatically.
If I don't suspend ASG and allow ASG to terminate and launch a new EC instance by manually stopping the instance and then ASG creating a new instance, then no issues in application coming up automatically in the new instance.
Can someone please guide me here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
