skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. If you’ve cloned an EC2 instance and need to verify the Delete on Termination setting, follow these steps:

    • Navigate to the EC2 console.
    • Select the cloned EC2 instance.
    • Go to the Storage tab and confirm the "Delete on Termination"
      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:

    aws ec2 modify-instance-attribute --instance-id <instance-id> --block-device-mappings file://mapping.json
    

    In mapping.json, specify the device name, for example /dev/sda1 or /dev/xvda, and for –DeleteOnTermination, specify false.

    [
      {
        "DeviceName": "device_name",
        "Ebs": {
          "DeleteOnTermination": false
        }
      }
    ]
    

    Reference Link:- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminate-instances-considerations.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search