How do I re-create a terminated EC2 instance?
Last updated: 2021-06-22
My Amazon Elastic Compute Cloud (Amazon EC2) instance was terminated, but I want to recover or restore data from that instance. Can I re-create a terminated EC2 instance?
Resolution
As part of an Amazon EC2 instance termination, the data on any instance store volumes associated with that instance is deleted. By default, the root Amazon Elastic Block Store (Amazon EBS) volume is automatically deleted.
It's not possible to recover either the original Amazon EC2 instance or any volumes that were deleted as part of the termination process. However, you can use the following methods to re-create the terminated instance:
- Launch a replacement EC2 instance using Amazon EBS snapshots or Amazon Machine Images (AMI) backups that were created from the terminated Amazon EC2 instance.
- Attach an EBS volume from the terminated instance to another EC2 instance. You can then access the data contained in those volumes.
Use the following methods to prevent instance termination and volume deletion:
- Enable termination protection of the EBS volume when you launch an EC2 instance. If you enable this option and the instance is later terminated, then the EBS root volume isn't deleted. You can then launch a new EC2 instance from the available root volume. For more information, see How can I prevent my Amazon EBS volumes from being deleted when I terminate Amazon EC2 instances?
- Set the instance shutdown behavior to stop the instance instead of terminating it. For more information, see Change the instance initiated shutdown behavior.
- If the instance is part of an Amazon EC2 Auto Scaling group, you can customize the termination policy or use scale-in protection. For more information, see Controlling which Auto Scaling instances terminate during scale in.
- In addition to regularly taking snapshots and AMIs to back up critical data, consider using termination protection to help prevent this issue in the future. You can also automate snapshots with Amazon Data Lifecycle Manager (Amazon DLM) and AWS Backup.
Related information
Did this article help?
Do you need billing or technical support?