1

I have created an EC2 Instance with "Delete on Termination" set to False at EBS Root storage. Now, I want to set it to True using AWS CLI.

Hiren Parghi
  • 1,795
  • 1
  • 21
  • 30

1 Answers1

2

To enable delete on termination for EBS:

aws ec2 modify-instance-attribute \
  --instance-id <...> \
  --block-device-mappings "[{\"DeviceName\": \"/dev/sdf\",\"Ebs\":{\"DeleteOnTermination\":true}}]"

To enable delete on termination for an instance:

aws ec2 modify-instance-attribute \
  --instance-id <...> \
  --instance-initiated-shutdown-behavior terminate
Yann
  • 2,426
  • 1
  • 16
  • 33