DVA-C02 Deployment Practice Question
A developer is using AWS Elastic Beanstalk to deploy a web application. The developer wants to run database migration scripts as part of the deployment process before the new application version starts serving traffic. Which Elastic Beanstalk configuration file should the developer use to define the migration commands?
⚠ Common exam trap
Test-takers frequently confuse `commands` with `container_commands`; candidates often pick `commands` because they sound similar, but they run at different lifecycle stages, and only `container_commands` guarantees execution after the application stack is ready but before traffic is routed.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
.ebextensions/<filename>.config with container_commands
`container_commands` in `.ebextensions/<filename>.config` runs commands after the application and web server have been set up but before the new application version starts serving traffic. This makes it the ideal place to execute database migration scripts that must complete before the environment accepts requests, ensuring data consistency.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
.ebextensions/<filename>.config with container_commands
Why this is correct
Elastic Beanstalk's .ebextensions/<filename>.config with container_commands are executed after the application and web server have been fully set up and are ready, but critically, before the new application version begins serving live traffic. This precise timing is ideal for database migrations, as the application can connect to the database to perform schema updates without impacting active users on the old version, ensuring a smooth transition for the new deployment.
- ✗
.ebextensions/<filename>.config with commands
Why it's wrong here
The commands section in an Elastic Beanstalk .ebextensions configuration file runs very early in the deployment process, specifically before the application code is deployed and the web server is configured. This execution phase is too premature for database migrations because the application context, including database connection details and ORM tools, is not yet available or configured. Attempting migrations at this stage would likely result in errors due to missing dependencies or an inability to connect to the database.
- ✗
Procfile
Why it's wrong here
A Procfile is primarily used in Elastic Beanstalk environments, especially those utilizing Docker, to declare the long-running processes that constitute the application. Its purpose is to define how the application runs, specifying commands to start web servers or worker processes, rather than defining one-off deployment-time tasks like database migrations. Therefore, it is unsuitable for executing lifecycle hooks or schema changes during the deployment process itself.
- ✗
buildspec.yml
Why it's wrong here
The buildspec.yml file is a configuration used exclusively by AWS CodeBuild to define the build commands and artifacts for a project. It specifies steps for compiling code, running tests, and packaging applications within a CodeBuild pipeline, which is a distinct phase from Elastic Beanstalk's deployment lifecycle. Consequently, buildspec.yml has no direct role in defining or executing commands during an Elastic Beanstalk application deployment or for performing database migrations on the deployed instances.
Go deeper
Related to this question
About these practice questions
This DVA-C02 question is part of Courseiva's 724-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.