Courseiva
DeploymenteasyMultiple ChoiceObjective-mapped

How to Set Environment Variables in Elastic Beanstalk Securely

A developer is deploying a Node.js application to AWS Elastic Beanstalk. The application uses environment variables for database credentials. What is the BEST way to securely provide these credentials to the application?

Quick Answer

The correct answer is to set environment properties in the Elastic Beanstalk environment configuration. This is the best approach because Elastic Beanstalk injects these properties as environment variables directly into the application’s runtime, allowing a Node.js application to securely access database credentials via `process.env` without ever hardcoding them in source code or deployment artifacts. On the AWS Certified Developer Associate DVA-C02 exam, this question tests your understanding of secure credential management and the principle of least privilege—a common trap is choosing to store credentials in a configuration file within the application bundle, which violates security best practices. Remember that Elastic Beanstalk environment properties are separate from your code, making them ideal for sensitive values like database passwords. A useful memory tip: think of environment properties as “runtime secrets” that stay out of your source code, keeping your deployments both secure and flexible.

⚠ Common exam trap

Candidates often think storing credentials in a configuration file (Option B) is acceptable because it separates code from configuration, but they overlook that the configuration file is still part of the deployment package and can be accessed by anyone with access to the artifact or the running environment.

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

Set environment properties in the Elastic Beanstalk environment configuration.

Elastic Beanstalk allows you to set environment properties in the environment configuration, which are injected as environment variables into the application's runtime. This approach keeps sensitive credentials out of the source code and deployment artifacts, adhering to the principle of least privilege and secure credential management. For a Node.js application, these environment variables can be accessed via `process.env`, providing a secure and flexible way to manage database credentials without hardcoding or storing them in files.

Answer analysis

Option-by-option breakdown

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

  • Store the credentials in a file in the source code repository.

    Why it's wrong here

    Storing in source control exposes secrets.

  • Store the credentials in the application's configuration file within the deployment package.

    Why it's wrong here

    Storing in the deployment package is insecure.

  • Hardcode the credentials in the application code.

    Why it's wrong here

    Hardcoding is insecure.

  • Set environment properties in the Elastic Beanstalk environment configuration.

    Why this is correct

    Environment properties are secure and easily managed.

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

Same concept, more angles

1 more way this is tested on DVA-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer is deploying a web application on AWS Elastic Beanstalk. The application uses a relational database and requires a custom environment variable for the database connection string. The developer has created an Elastic Beanstalk environment and wants to set the environment variable securely without exposing it in the source code or configuration files. The developer also wants to ensure that the environment variable is available to the application instances at deployment time. What is the BEST way to achieve this?

medium
  • A.Set the environment variable using the Elastic Beanstalk console or CLI by configuring environment properties.
  • B.Store the connection string in AWS Systems Manager Parameter Store and retrieve it from the application code at runtime.
  • C.Hardcode the connection string in the application code and commit it to the source repository.
  • D.Store the connection string in a file named 'env.txt' in the application source bundle and read it at application startup.

Why A: The best because Elastic Beanstalk allows setting environment properties in the environment configuration, which are securely passed to the application instances and automatically injected as environment variables without exposing them in source code. This meets the requirement for secure, deployment-time availability. Option B (Parameter Store) is less suitable because the application must retrieve it at runtime, adding complexity and potential latency, and it is not automatically injected like environment properties. Option C is insecure as it exposes the connection string in source code. Option D is insecure because the file is stored in plain text within the source bundle.

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.