Home › Forums › AWS › AWS Certified Solutions Architect Associate › ASG life cycle and Lambda
Tagged: AWSSolutionsArchitectAssociate
-
ASG life cycle and Lambda
Carlo-TutorialsDojo updated 3 years, 3 months ago 2 Members · 2 Posts -
A company has an application hosted in an Auto Scaling group of Amazon EC2 instances across multiple Availability Zones behind an Application Load Balancer. There are several occasions where some instances are automatically terminated after failing the HTTPS health checks in the ALB and then purges all the ephemeral logs stored in the instance. A Solutions Architect must implement a solution that collects all of the application and server logs effectively. She should be able to perform a root cause analysis based on the logs, even if the Auto Scaling group immediately terminated the instance.
What is the EASIEST way for the Architect to automate the log collection from the Amazon EC2 instances?
Correct answer:
Add a lifecycle hook to your Auto Scaling group to move instances in the Terminating state to the Terminating:Wait state to delay the termination of unhealthy Amazon EC2 instances. Configure a CloudWatch Events rule for the EC2 Instance-terminate Lifecycle Action Auto Scaling Event with an associated Lambda function. Trigger the CloudWatch agent to push the application logs and then resume the instance termination once all the logs are sent to CloudWatch Logs.
The only thing I am not able to understand is, why Lambda is used? Can you guys please check this and clarify me?
-
Hello pskarthic,
Thank you for your feedback.
Based on the answers given and the scenario, CloudWatch Events is used to monitor the terminating auto-scaling event. If that event happens, CW will invoke a Lambda function that triggers the CW agent inside the affected instance. The CW agent publishes the logs before terminating the instance.
Regards,
Carlo @ Tutorials Dojo
Log in to reply.