How do I set my instance so that all the volumes associated with it automatically delete on terminate?

Teradata Database on AWS
Teradata Employee

How do I set my instance so that all the volumes associated with it automatically delete on terminate?

 
2 REPLIES
Teradata Employee

Re: How do I set my instance so that all the volumes associated with it automatically delete on terminate?

If it's Teradata product in Marketplace, the volumes will be removed automatically when the instance is terminated.

For others, in launching process, at "Add Storage" step, check the "Delete on Termination" box on the volumes you what to delete on termination. By default, the root volume will be checked, but others not.

Teradata Employee

Re: How do I set my instance so that all the volumes associated with it automatically delete on terminate?

If you already have an instance running without the “delete on terminate” option enabled, here is how to modify this option using AWS CLI:

  1. From the AWS console home, click on EC2 under Amazon Web Services
  2. Click on Instances from the menu on the left under INSTANCES
  3. Take note of the Instance ID and the Public IP of the instance you want to modify
  4. Make sure that the instance is in “running” state
  5. Connect to the instance using SSH and the public IP address you wrote down earlier
  6. If you do not have your AWS CLI configured, please refer to Configuring AWS CLI and configure it before proceeding to the next step
  7. Run the following commands from the command line prompt to get the information on all the volumes associated with the instance

    # sudo su -

    # aws ec2 describe-instance-attribute --instance-id [instance_id] --attribute blockDeviceMapping

        Replace [instance_id] with the one you wrote down from step 3
  8. Write down the DeviceName of the volume that has “DeleteOnTermination” set to “false”
  9. Run the following command:

    # aws ec2 modify-instance-attribute --instance-id [instance_id] --block-device-mappings "[{\"DeviceName\": \"[DeviceName]\",\"Ebs\":{\"DeleteOnTermination\":true}}]"

        Replace [instance_id] with your instance id and [DeviceName] with the one you wrote down from step 8
  10. Run the following command again and verify that “DeleteOnTermination” is set to true for the device you modified

    # aws ec2 describe-instance-attribute --instance-id [instance_id] --attribute blockDeviceMapping