How to Enable Termination Protection for an AWS EC2 Instance

How to Enable Termination Protection for an AWS EC2 Instance

AWS EC2 is a scalable, reliable and low-priced offering from Amazon for the user’s virtual computation or hosting needs. AWS EC2 instances can be launched or terminated any time. However, there may be a probability that the user may terminate the production instance by accident. To overcome the above mentioned problem, AWS provides a functionality called termination protection. Once enabled, the user cannot terminate the instance from the console or the command line API.

The present guide demonstrates how to enable termination protection for an instance.

1. Enter your AWS console  and select the EC2 service. From the EC2 dashboard, click on the Running Instances or the Instance link.

2. Select the running instance.

[Newvem scans and identifies the status of your security group configurations, continuously monitors their status, and alerts you of vulnerabilities. Learn more about Newvem's features]

3. Select the instance and click on the “Actions? menu from the top. Select “Change Termination Protection?.

4. AWS will acknowledge before enabling the termination protection. Confirm the instance ID and the current protection status. Click on “Yes, Enable?.

5. The termination protection will now be enabled. When the user checks the instance details at the bottom, it will show that termination protection is now enabled.

6. When the user tries to terminate an instance for which termination protection is enabled, AWS will not allow and show a corresponding message.

7. To disable the termination protection, select “Change Termination protection? from the “Action? menu as explained in step#3. Check that the current status is enabled and disable it with the “Yes, Disable? button.

8. The termination protection will now be disabled in the instance information.

9. The above mentioned steps explain how to change the termination protection for a running instance. If the user wants to set termination protection while launching the instance, it can be enabled. Launch the instance, as explained in How to launch an EC2 instance. In step#6, select the Prevention against accidental termination. This will enable termination protection during the instance launch.

10. To run the above mentioned steps through the command line interface, first setup AWS EC2 CLI to launch an instance with the command line option, as explained in How to install AWC CLI to Windows.

11. Run the following command to check the current status of API termination (If it is false, the termination protection is disabled).

Ec2-describe-instance-attribute --region <region name> <instance id> --disable-api-termination

To enable the termination protection:

Ec2-modify-instance-attribute --region <region name> <instance id> --disable-api-termination true

If instance termination protection is enabled, the instance cannot be terminated and AWS will show an error.

12. The actual output is shown below, whereby the user changed the instance type from medium to micro.

[Newvem analytics tracks your AWS cloud utilization:

Get Started with Newvem for free or learn more about Newvem's features]

Keywords: Amazon AWS elastic cloud services, Cloud Performance, Cloud Availability, Cloud Utilization, Amazon S3, Amazon Web Services, Cost optimization, Termination Protection, AWS EC2, EC2 Dashboard, AWS Console

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations