I want to terminate my Amazon Elastic Compute Cloud (Amazon EC2) instance.
Your EC2 instance might not terminate for the following reasons:
- The instance is in the stopping or pending state.
- Termination protection is turned on for the instance.
- There are incorrect permissions on the AWS Identity and Access Management (IAM) policy attached to the role or user attempting to terminate the instance.
- The instances is part of an Auto Scaling group.
The instance is in the stopping or pending state
If the instance appears to be "stuck" in the stopping state, then see Troubleshoot stopping your instance. After you stop the instance, you can then terminate it.
The instance might remain in the pending state for more than 30 minutes after you attempt to launch it. If it does, then use the AWS Command Line Interface (AWS CLI) to stop the instance. In the AWS CLI, run the stop-instances command with a --force option or run the terminate-instances command
Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.
Termination protection is turned on for the instance
If termination protection is turned on, then you can't terminate the instance. For information on turning off termination protection on your instance, see Enable termination protection. Follow the instructions in To disable termination protection for a running or stopped instance.
There are incorrect permissions on the IAM policy attached to the role or user attempting to terminate the instance
The IAM policy attached to the role or user attempting to terminate the instance must allow the ec2:TerminateInstances API. For information on editing IAM policies, see Editing IAM policies.
The instance is a part of an Auto Scaling group
If the terminated instance is a part of an Auto Scaling group, then a replacement instance will be launched by the Auto Scaling group. This is done to maintain the desired count and is an expected behavior of the Auto Scaling group. In the AWS CLI, run the terminate-instance-in-auto-scaling-group command to terminate the instance.