Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Detaching Unhealthy ASG Instance instead of Terminating #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xzaws
Copy link

@xzaws xzaws commented Apr 17, 2024

This article addresses the need to preserve unhealthy AWS Auto Scaling Group (ASG) instances for analysis. It introduces a Lambda-based solution to retain these instances, circumventing ASG's automatic termination. The piece outlines how to use CloudFormation for easy setup, enabling detailed investigation of instance failures without affecting ASG performance. The goal is to enhance troubleshooting efficiency and system reliability through automated, user-friendly configurations.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This article addresses the need to preserve unhealthy AWS Auto Scaling Group (ASG) instances for analysis. It introduces a Lambda-based solution to retain these instances, circumventing ASG's automatic termination. The piece outlines how to use CloudFormation for easy setup, enabling detailed investigation of instance failures without affecting ASG performance. The goal is to enhance troubleshooting efficiency and system reliability through automated, user-friendly configurations.

for asg_name in ASG_NAMES:
unhealthy_instances, desired_capacity = process_asg(asg_name)
max_detach_by_percent = int(desired_capacity * 0.1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this line to:
max_detach_by_percent = max(int(desired_capacity * 0.1),1) # Ensure minimum 1 if there are unhealthy instances.
Otherwise, when the desired capacity is less than 10. This script won't detach any unhealthy instance. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant