`botocore.exceptions.WaiterError: Waiter InstanceRunning failed: Waiter encountered a terminal failure state: For expression "Reservations[].Instances[].State.Name" we matched expected path: "terminated"`
IntermediateTroubleshootingboto3, HTTP & API errors
Answer
Likely causes → The instance terminated right after launch: insufficient capacity, EBS/KMS key permission issue on an encrypted volume, invalid AMI/instance type combination, or a Spot interruption.
Diagnose →
aws ec2 describe-instances --instance-ids i-... --query "Reservations[].Instances[].StateReason"
Common reason: Client.InternalError: Client error on launch (often KMS permissions for encrypted EBS).
Fix → Fix the root cause shown in StateReason (grant the role/ASG service-linked role access to the KMS key, change AZ or instance type).
Prevent → Log StateReason automatically when a waiter fails.
More on boto3, HTTP & API errors
`botocore.exceptions.NoCredentialsError: Unable to locate credentials`Beginner`botocore.exceptions.NoRegionError: You must specify a region.` even though `AWS_REGION` is set.Intermediate`botocore.exceptions.ClientError: An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation.`Beginner`An error occurred (ExpiredToken) when calling the ... operation: The security token included in the request is expired` midway through a long job.Advanced`An error occurred (RequestLimitExceeded) when calling the DescribeInstances operation (reached max retries: 4): Request limit exceeded.`Intermediate`An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid.`Beginner