Termination Protection in EC2 Instance – One of all methods to Protect Your AWS Images Against Accidental Data Loss

Termination Protection in EC2 Instance – One of all methods to Protect Your AWS Images Against Accidental Data Loss

TERMINATION PROTECTION
Clock Icon2020.05.09

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Hi, I'm Nghi. ギーと申します。

Today, I will write more about one of my experience while working with EC2 Instance: That is Termination Protection.

What is Termination Protection?

As far as I know, We have following options below when configuring to help protect against data loss caused by accidental termination of an Amazon EC2 instance:

  • Enable Termination Protection
  • Regularly back up your data
  • Output data to another AWS service or the source.

Sure that the highest recommendation is "Regularly back up your data", but while working with EC2 Instance, Termination Protection is also important. We can understand easily that Termination Protection is one of all methods to protect your AWS Images Against accidental data loss. I will show you more below!

For purpose?

Termination Protection prevents an instance from being accidentally terminated by requiring that you disable the protection before terminating the instance. And when you want to Terminate an Instance, a pop up will be shown and notices :

 

How to check?

We will use this command below to check the status of Termination Protection attribute of your EC2 Instance

But maybe this error will be shown:

You must specify a region for your EC2 Instance first by running "AWS configure" And If it is true, it will be shown as below: For example, my EC2 Instance has the Instance Id like this:

And After I run: The result is:

It means I disabled Termination Protection, as well, If it was enabled, the Value will get "true".

 

How to set up?

We have two ways to set up Termination Protection for EC2 Instance

1.Using Console in step 3 while launching  an EC2 Instance:

Enable at this field:

 

2.Using command if you have not enabled Termination Protection while launching an EC2 Instance:

You can check the information of your EC2 Instance by command:

$aws ec2 modify-instance-attribute --disable-api-termination --instance-id   to disable $aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id to enable

This command will help you modifies the specified attribute of the specified instance, and you just can specify only one attribute at a time.

Summary

While working with EC2 Instance, I have many problems and also acquired new knowledge and I will continue discovering more. I will write about new things that I could learn more.

I'm Nghi. Thanks for your attention!

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.