Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A developer is deploying a web application using AWS Elastic Beanstalk. The application uses a MySQL database. During deployment, the developer needs to apply database schema migrations. Which approach should the developer use to run database migrations as part of the Elastic Beanstalk deployment?

⚠ Common exam trap

Test-takers frequently confuse the deployment lifecycle hooks of different AWS services (e.g., CodeDeploy's AppSpec vs. Elastic Beanstalk's .ebextensions) and assume any migration script can be plugged into any deployment tool, ignoring that Elastic Beanstalk has its own proprietary configuration mechanism.

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

Use an .ebextensions configuration file to run a migration script during deployment.

Elastic Beanstalk supports .ebextensions configuration files that can execute custom commands or scripts during deployment. By placing a migration script (e.g., a shell script that runs `mysql` commands or a framework migration tool) in the `.ebextensions` directory and using the `commands` or `container_commands` key, the developer can ensure the migration runs automatically after the application is deployed but before the new environment serves traffic. This approach integrates the migration into the deployment lifecycle without external dependencies.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Use an .ebextensions configuration file to run a migration script during deployment.

    Why this is correct

    Using an .ebextensions configuration file is the correct approach because Elastic Beanstalk processes these files during deployment, allowing developers to execute custom commands on the EC2 instances. Specifically, `container_commands` or `commands` within these YAML files can run database migration scripts at a specific point in the application deployment lifecycle. This ensures the database schema is updated in sync with the new application code before it starts serving traffic.

  • Configure an RDS event subscription to trigger a Lambda function that runs migrations.

    Why it's wrong here

    Configuring an RDS event subscription to trigger a Lambda function is unsuitable because RDS event subscriptions are designed to notify about database instance-level events, such as reboots, failovers, or backup completions. These events are unrelated to the deployment of a new application version to an Elastic Beanstalk environment. Therefore, this mechanism cannot reliably trigger a migration script precisely when a new web application version is deployed.

  • Run the migration script as a scheduled task using CloudWatch Events.

    Why it's wrong here

    Running the migration script as a scheduled task using CloudWatch Events (now EventBridge) is inappropriate because scheduled tasks operate on a fixed time-based schedule, not in response to an application deployment event. A database migration needs to execute precisely when a new application version is deployed to ensure schema compatibility. A scheduled task would run independently of the deployment lifecycle, potentially leading to schema mismatches or premature execution.

  • Use AWS CodeDeploy's AppSpec file to run the migration script.

    Why it's wrong here

    Using AWS CodeDeploy's AppSpec file to run the migration script is incorrect because Elastic Beanstalk manages its own deployment process and lifecycle hooks, distinct from a standalone CodeDeploy deployment. While Elastic Beanstalk leverages underlying AWS services, it provides a higher-level abstraction for application deployments. CodeDeploy is a separate service for deploying applications to various compute services, and its `AppSpec` file is not the native or intended mechanism for customizing deployments within an Elastic Beanstalk environment.

About these practice questions

One of 724 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.