Protecting your EC2 instances and EBS volumes using termination protection
You can always delete an EC2 instance that is no longer needed, and the process is called terminating your instance. Simultaneously, you need to be very careful not to accidentally delete any instance in use, as this will cause downtime. This is where enabling instance termination protection comes in handy.
By default, you can delete any instance using the following:
- EC2 console
- AWS command-line interface (CLI)
- Application Programming Interface (API)
We can use the DisableApiTermination
attribute to control whether we can terminate the instance using the console, the AWS CLI, or an API. This attribute can be set at the following times:
- During instance launch
- When the instance is running (for EBS-backed instance)
- While the instance is in a shutdown state
To enable termination protection of a running instance, proceed as follows:
- Go to the EC2 console at...