Courseiva
DeploymenthardMultiple ChoiceObjective-mapped

DVA-C02 Deployment Practice Question

A developer is using AWS Elastic Beanstalk to deploy a Node.js application. The developer wants to run a custom script to set environment variables before the application starts. Which configuration file and location should the developer use?

⚠ Common exam trap

A common mix-up: candidates confuse `container_commands` with `commands` (which run before the application setup) or assume a Procfile is used in Elastic Beanstalk, when in fact Elastic Beanstalk uses platform-specific hooks like `.platform/hooks/prebuild` or `.ebextensions` for custom scripts.

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

Add a configuration file in the .ebextensions directory that uses container_commands.

`.ebextensions` configuration files with `container_commands` allow you to run custom commands before the application starts. `container_commands` execute after the application and web server have been set up but before the application is deployed, making them ideal for setting environment variables or running setup scripts. The files must be in YAML or JSON format and placed in the `.ebextensions` directory at the root of your source bundle.

Answer analysis

Option-by-option breakdown

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

  • Add a configuration file in the .ebextensions directory that uses container_commands.

    Why this is correct

    Elastic Beanstalk configuration files placed in the `.ebextensions` directory provide a robust mechanism for customizing the environment. `container_commands` are specifically designed to execute custom commands on the EC2 instances after the application source code has been deployed and dependencies installed, but critically, before the application server starts processing requests. This execution phase makes them ideal for running custom scripts, performing database migrations, or setting up application-specific configurations that depend on the deployed code.

  • Add a Procfile to the application root.

    Why it's wrong here

    A `Procfile` in the application root is used by Elastic Beanstalk to declare the command that starts your application's web process or other worker processes. It specifies the entry point for your application, such as `web: npm start` for a Node.js application, defining how the application should be run as a long-running service. However, a `Procfile` is not intended for executing arbitrary one-time custom scripts or performing setup tasks during the deployment lifecycle; its sole purpose is to define process types.

  • Place a shell script in the .ebextensions/scripts directory.

    Why it's wrong here

    While placing a shell script in the `.ebextensions/scripts` directory makes it available within the deployment bundle on the EC2 instances, Elastic Beanstalk does not automatically execute scripts found there. For a script to run during deployment, it must be explicitly invoked by a command within a `.ebextensions` configuration file, such as a `commands` or `container_commands` section. Simply placing a script in this directory without referencing it will not trigger its execution.

  • Add a cron.yaml file to the .ebextensions directory.

    Why it's wrong here

    A `cron.yaml` file placed in the `.ebextensions` directory is specifically used to define recurring scheduled tasks, or cron jobs, that Elastic Beanstalk will configure on the environment's EC2 instances. These jobs run at specified intervals and are typically used for background processing, maintenance, or data synchronization. This file is not intended for executing one-time custom scripts during the deployment process or for general environment configuration tasks.

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.