Packer "Error waiting for instance" state timeout in CI
After launching, Packer polls until the instance reaches a ready state. If capacity, a bad AMI, or a startup failure prevents it, the poll times out and the build aborts.
What this error means
packer build fails with "Error waiting for instance (i-...) to become ready" or a state timeout after the instance was launched.
==> amazon-ebs.ubuntu: Error waiting for instance (i-0123456789abcdef0) to become
ready: timeout while waiting for state to become 'running' (last state: 'pending')Common causes
Capacity or a stuck pending state
The instance stays in pending, sometimes from a capacity issue or an instance type that cannot launch in the chosen subnet.
A short state timeout for a slow region
The default wait is too short for a slow-starting instance in a busy region.
How to fix it
Use an available instance type and subnet
- Check that the instance type is offered in the target Availability Zone.
- Choose a subnet in an AZ with capacity for that type.
- Re-run the build.
Raise the state timeout
Give the instance more time to reach the running state before Packer gives up.
source "amazon-ebs" "ubuntu" {
aws_polling {
delay_seconds = 15
max_attempts = 80
}
}How to prevent it
- Pick instance types available in the chosen AZ.
- Raise
aws_pollinglimits for slow regions. - Alert on repeated pending-state timeouts in the account.