Search code examples
amazon-web-servicesamazon-ec2

Failed to terminate ec-2 instance: How to modify its 'disableApiTermination' attribute from EC2 Dashboard?


I opened a free tier instance for some practice.

I tried to terminate it, as I've done many times successfully.

But upon selecting Terminate instance from the dropdown;

enter image description here

I got the following error:

Failed to terminate the instance <instance id>
The instance '<instance id>' may not be terminated. Modify its 'disableApiTermination' instance attribute and try again.

Where can I find the disableApiTermination attribute?


Solution

  • According to the documentation

    To disable termination protection for a running or stopped instance

    1. Select the instance, and choose Actions, Instance Settings, Change Termination Protection.

    2. Choose Yes, Disable.

    enter image description here

    enter image description here

    Using AWS CLI you can use this command

    aws ec2 modify-instance-attribute --instance-id <instance-id> --no-disable-api-termination