Set Delete on Termination for EBS Volume

Girish V P
ADIBI Technologies, Basavanagudi, Blore.
1 min readNov 21, 2020

Some times it is important negate “Delete on Termination” to avoid the EBS volume to be deleted while EC2 instance is terminated. The steps given below.

Prerequisite: Instance which execute the below operation should have enough permission to change the attribute. It can be in the form of of IAM key installed on the EC2 instance or IAM Role.
  1. Create json file with following contents. ( Eg. test.json)
[
{
"DeviceName": "/dev/sdb",
"Ebs": {
"DeleteOnTermination": false
}
}
]

2. Execute the commands below

aws ec2 modify-instance-attribute --instance-id Your_Instance_ID  --block-device-mappings file://test.json

Screenshots before and After

Conclusion

We are able to set Delete on Termination to false for EBS volume

--

--