Q48 — AWS DOP-C02 Ch.3

Question 48 of 100 | ← Chapter 3

A company uses AWS CodeDeploy to automate deployments of a Java-Apache Tomcat application running on Apache web servers. The development team has completed initial setup, creating a deployment group for the development environment and performing functional testing within the application. Next, the team will create additional deployment groups for staging and production.

Correct Answer: B. Create a script that uses the CodeDeploy environment variable DEPLOYMENT_GROUP_NAME to identify which deployment group the instance belongs to. Use this information to configure log level settings. In the appspec.yml file, reference this script as part of the BeforeInstall lifecycle hook.

Explanation

AWS CodeDeploy provides built-in environment variables such as DEPLOYMENT_GROUP_NAME, which can be accessed directly by scripts during deployment. AWS documentation confirms CodeDeploy injects these variables automatically without extra configuration. Option B triggers the script during the BeforeInstall phase and uses the environment variable to dynamically configure log levels—avoiding separate script versions or custom environment variables. Option A adds complexity and permissions overhead via EC2 metadata and API calls; Option C increases maintenance burden with custom environment variables; Option D’s DEPLOYMENT_GROUP_ID is not a documented standard CodeDeploy environment variable. Option B meets the minimal management overhead requirement using natively supported variables.