Elastic Beanstalk "Instance deployment failed" from .ebextensions in CI
Beanstalk applies .ebextensions config files (packages, files, commands, container_commands) during deploy. A directive that errors fails the instance deployment with "Instance deployment failed" and a reference to the config.
What this error means
eb deploy fails with "Instance deployment failed. For details, see service log." and eb-engine.log shows a failing container_command or a YAML/config error in a .ebextensions file.
[ERROR] Instance deployment failed. For details, see 'eb-engine.log'.
[ERROR] command 01_migrate (in .ebextensions/db.config) failed.
Command failed on instance. Return code: 1Common causes
A container_command exited non-zero
A migration, build, or setup command in container_commands failed (a missing tool, a wrong path, a non-zero exit), which fails the whole deploy.
A malformed .ebextensions file
Invalid YAML, an unknown key, or a package that cannot be installed makes Beanstalk reject the config during the deploy.
How to fix it
Read eb-engine.log for the failing directive
- Fetch the logs and open eb-engine.log.
- Find the named command or config key that failed and its output.
- Correct the command or config and redeploy.
eb logs --allMake commands robust and valid
Use absolute paths, guard one-off commands with leader_only, and validate the YAML.
container_commands:
01_migrate:
command: "/var/app/venv/*/bin/python manage.py migrate"
leader_only: trueHow to prevent it
- Validate .ebextensions YAML before committing.
- Use leader_only for one-off tasks like migrations.
- Reference absolute paths and tools known to exist on the platform.