- Newest
- Most votes
- Most comments
You can use the Auto Scaling Lifecycle hooks that enable you to perform custom actions by pausing instances when an Auto Scaling group launches or terminates them. For your use case, you can do the following:
- Enable lifecycle hooks for terminating EC2 instances.
- When the instance is in the Terminating Wait state, perform a custom action using an AWS lambda function, where you can take the respective instance snapshot.
- After the above action is successful, you can call the complete-lifecycle-action API.
You can attach a secondary elastic network interface to the terminating instance using EC2 Auto Scaling. For more information, see Creating a launch template for an Auto Scaling group. Also, you can create the snapshot of this instance using the AWS CLI.
In your AWS Lambda function, you can create a new launch configuration with this latest configuration and update the Auto Scaling group to use new configuration. When the new instance is launched, it inherits the new configuration.
Can you please provide some reference links or examples or documentation supporting your answer? I am relatively new to this. Some links/examples will help a lot.
Relevant content
- Accepted Answerasked 5 months ago
- asked 2 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 years ago
This answer is at a very high level. Some more detail will be definitely needed, so that it can help others.