# EC2 Spot Instance termination notice: Your Spot Instance 'i-1234567890abcdef0' is terminated because the Spot price exceeded the maximum price you are willing to pay.

- **ID:** `cloud/aws-ec2-spot-instance-termination`
- **Domain:** cloud
- **Category:** runtime_error
- **Error Code:** `SpotInstanceTermination`
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

The Spot Instance's bid price is lower than the current Spot market price, causing AWS to reclaim the instance.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| EC2 Spot Instances (all regions) | active | — | — |
| AWS CLI 2.13.0 | active | — | — |

## Workarounds

1. **Use a Spot Fleet or EC2 Fleet with multiple instance types and bid prices. Example: `aws ec2 request-spot-fleet --spot-fleet-request-config file://config.json` where config.json includes diverse instance types (e.g., m5.large, c5.large) and a max bid equal to the On-Demand price. This increases chances of capacity availability.** (80% success)
   ```
   Use a Spot Fleet or EC2 Fleet with multiple instance types and bid prices. Example: `aws ec2 request-spot-fleet --spot-fleet-request-config file://config.json` where config.json includes diverse instance types (e.g., m5.large, c5.large) and a max bid equal to the On-Demand price. This increases chances of capacity availability.
   ```
2. **Implement graceful shutdown handling. Use the EC2 metadata endpoint to check for termination notices (http://169.254.169.254/latest/meta-data/spot/termination-time) and save state before termination. Example script: `curl http://169.254.169.254/latest/meta-data/spot/termination-time 2>/dev/null && echo "Termination imminent"`** (75% success)
   ```
   Implement graceful shutdown handling. Use the EC2 metadata endpoint to check for termination notices (http://169.254.169.254/latest/meta-data/spot/termination-time) and save state before termination. Example script: `curl http://169.254.169.254/latest/meta-data/spot/termination-time 2>/dev/null && echo "Termination imminent"`
   ```

## Dead Ends

- **Increase the bid price to the On-Demand price** — Setting bid to On-Demand price defeats the purpose of Spot Instances and may still not guarantee persistence during high demand. AWS may still terminate if capacity is reclaimed. (60% fail)
- **Use a different instance type without changing bid** — Different instance types have different Spot markets; the same bid may still be too low for the new type. (70% fail)
