I have cloned an AWS EC2 instance and attached it to an existing volume (of another EC2 instance).
Now I want to terminate the cloned instance but I want to keep the volume.
How do I make sure that the volume won’t be deleted after I terminate the cloned instance?
2
Answers
Take a look at the Amazon EBS Volume in the EC2 management console. There is a Delete on Termination option against each volume that determines whether it will be deleted when the instance is Terminated.
By default, root volumes will be deleted (since they are mostly just copies of an AMI) but additional volumes will not be deleted by default. However, you can change those settings.
See also: Preserve the EBS root volume when an Amazon EC2 instance terminates | AWS re:Post
If you’ve cloned an EC2 instance and need to verify the Delete on Termination setting, follow these steps:
setting.
If it is set to No, deleting the cloned EC2 instance will not delete the associated volume.
However, if it is set to Yes, modifying Delete on Termination for a running server is only possible through AWS CLI.
The AWS Console allows this setting to be adjusted only during the server’s launch.
To modify Delete on Termination using AWS CLI:
In mapping.json, specify the device name, for example /dev/sda1 or /dev/xvda, and for –DeleteOnTermination, specify false.
Reference Link:- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminate-instances-considerations.html