DVA-C02 Question 216
Select 2You are deploying a Node.js application using AWS Elastic Beanstalk. The application requires a specific version of Node.js and additional environment variables for configuration. Which steps should you take to ensure a successful deployment?
- A
Specify the desired Node.js version in a
.platformfolder with aplatform.yamlfile in the application source bundle. - B
Use an
.ebextensionsfolder to define environment variables via configuration files. - C
Set the Node.js version and environment variables directly in the Elastic Beanstalk console after deploying the application.
- D
Include a
package.jsonfile in the source bundle that specifies the required Node.js version. - E
Use the Elastic Beanstalk CLI commands to create an environment and specify the Node.js version during creation.
Show answer and explanation
Correct answers: B, D
Explanation
To ensure a successful deployment of a Node.js application on Elastic Beanstalk, you should include a package.json file in the application source bundle to specify the required Node.js version. Additionally, environment variables can be configured using .ebextensions configuration files during deployment. These steps allow for automated and repeatable deployments while adhering to best practices.
- A. Incorrect.
Incorrect: Elastic Beanstalk does not use a
.platformfolder orplatform.yamlfile for specifying the runtime or configuration. This is not a valid step for deploying a Node.js application. - B. Correct.
Correct: The
.ebextensionsfolder can contain configuration files (e.g.,.config) where you can define environment variables and other settings for the Elastic Beanstalk environment. - C. Incorrect.
Incorrect: While you can set environment variables in the Elastic Beanstalk console, this is not a recommended approach for automating deployments or version control. Additionally, the Node.js version cannot be set directly through the console post-deployment.
- D. Correct.
Correct: Including a
package.jsonfile in the source bundle allows Elastic Beanstalk to detect and use the required Node.js version specified in theenginesfield. - E. Incorrect.
Incorrect: The Elastic Beanstalk CLI does not allow you to directly specify the Node.js version during environment creation. The Node.js version is determined by the platform configuration or the
package.jsonfile.