# How to enable termination protection on EC2

How-to guides · Updated 16 November 2026

**Short answer:** In the EC2 console, select the instance and choose Actions, Instance settings, Change termination protection, then enable it. On the CLI, run aws ec2 modify-instance-attribute --instance-id i-0123456789abcdef0 --disable-api-termination. It blocks TerminateInstances calls from the console, CLI and API until someone turns it off, but it doesn't stop Auto Scaling, Spot interruptions or an OS shutdown configured to terminate.

## Turn it on, check it, turn it off

```
# Enable
aws ec2 modify-instance-attribute --instance-id i-0123456789abcdef0 \
  --disable-api-termination

# Check (true = protected)
aws ec2 describe-instance-attribute --instance-id i-0123456789abcdef0 \
  --attribute disableApiTermination --query 'DisableApiTermination.Value'

# Disable (needed before you can terminate)
aws ec2 modify-instance-attribute --instance-id i-0123456789abcdef0 \
  --attribute disableApiTermination --value false

# Launch new instances already protected
aws ec2 run-instances --image-id ami-0abcdef1234567890 --instance-type t3.micro \
  --disable-api-termination
```

The CLI also accepts `--no-disable-api-termination` as the shorthand for switching it off. The double negative in the attribute name trips people up: *disable API termination = true* means protection is on.

## Console steps

1. Open the Amazon EC2 console and go to **Instances**.
2. Select the instance, then choose **Actions** > **Instance settings** > **Change termination protection**.
3. Tick **Enable** and save. When launching, the same setting is under the advanced details section.

Trying to terminate a protected instance fails with an `OperationNotPermitted` error that names termination protection.

## What it does not protect against

| Scenario | Protected? | Use instead |
|---|---|---|
| Someone terminates it in the console or API | Yes | — |
| Auto Scaling scale-in or health replacement | No | Instance scale-in protection; Standby |
| `shutdown` inside the OS with shutdown behaviour = terminate | No | Set shutdown behaviour to stop |
| Spot interruption | No | On-Demand capacity for critical work |
| Someone *stopping* it | No | Stop protection (`--disable-api-stop`) |
| A user who can call `ModifyInstanceAttribute` | Only until they turn it off | IAM or SCP deny on termination for tagged instances |

Termination protection is a guard against accidents, not a security control. For important instances, also keep `DeleteOnTermination` false on data volumes and take regular snapshots.

## Protect a whole environment

For more than a handful of instances, apply it by tag and back it with a policy, so protection doesn't depend on someone remembering a checkbox:

```
IDS=$(aws ec2 describe-instances \
  --filters Name=tag:env,Values=prod Name=instance-state-name,Values=running,stopped \
  --query 'Reservations[].Instances[].InstanceId' --output text)
for id in $IDS; do
  aws ec2 modify-instance-attribute --instance-id "$id" --disable-api-termination
done
```

Then add an IAM policy (or an SCP across the organisation) that denies `ec2:TerminateInstances` and `ec2:ModifyInstanceAttribute` on instances tagged `env=prod` for everyone except a break-glass role. Termination protection stops slips of the mouse; the deny stops a script or a colleague with broad permissions from undoing it casually.

## Check before and after

- Run the check command above for every instance you consider critical; a quick `describe-instances` loop with `describe-instance-attribute` makes an inventory.
- CloudFormation and Terraform: set the property (`DisableApiTermination` / `disable_api_termination`) in the template, or the next deploy may revert a manual change.
- Before decommissioning, remember to switch it off; scripts that terminate in bulk will fail on protected instances, which is the point, but can leave half-finished clean-ups.

## Questions

### How do I change termination protection with the AWS CLI?

Use aws ec2 modify-instance-attribute with --disable-api-termination to enable it, and --no-disable-api-termination (or --attribute disableApiTermination --value false) to disable it.

### Does termination protection prevent Auto Scaling from terminating an instance?

No. Use instance scale-in protection on the Auto Scaling group for that, and remember health checks can still replace unhealthy instances.

### Does termination protection stop the instance being stopped?

No. It only blocks termination. Stop protection is a separate attribute, set with --disable-api-stop.

## When this happens away from your desk

Production guardrails matter most when you are acting quickly. CloudConsole, a phone app for AWS, is built with protections like these in mind, showing which resources are production before anything changes.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Enable termination protection for an EC2 instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-termination-protection.html)
- [Amazon EC2 User Guide](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/)

## Related

- [aws ec2 modify-instance-attribute](https://cloudconsole.dev/cli/ec2-modify-instance-attribute)
- [aws ec2 terminate-instances](https://cloudconsole.dev/cli/ec2-terminate-instances)
- [aws ec2 run-instances](https://cloudconsole.dev/cli/ec2-run-instances)
- [How to stop an EC2 instance in an Auto Scaling group](https://cloudconsole.dev/how-to/stop-ec2-instance-in-auto-scaling-group)
- [How to find who deleted a resource in AWS](https://cloudconsole.dev/how-to/find-who-deleted-aws-resource)
- [How to add my IP to an AWS security group](https://cloudconsole.dev/how-to/add-my-ip-to-security-group)

---

Source: https://cloudconsole.dev/how-to/enable-ec2-termination-protection

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
