A team uses AWS CodeDeploy for deployments of a Java/Tomcat application with an Apache webserver. They have separate deployment groups for developer, staging, and production and want to change the Apache log level dynamically during deployment based on the deployment group without creating separate application revisions or multiple script versions. How can they achieve this with minimal management overhead?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a script that reads the CodeDeploy environment variable DEPLOYMENT_GROUP_NAME to determine which deployment group the instance belongs to, set the Apache log level based on that value, and reference this script in the BeforeInstall lifecycle hook in appspec.yml..
Why this is the answer
The correct answer leverages the DEPLOYMENTGROUPNAME environment variable, which CodeDeploy automatically makes available during deployments. This allows a single script to dynamically adjust the Apache log level based on the current deployment group (developer, staging, or production) without needing separate application revisions or complex logic. Placing this script in the BeforeInstall lifecycle hook ensures the log level is configured before the application's new version is installed. The other options are less efficient or incorrect: Tagging EC2 instances and calling the EC2 API adds unnecessary complexity and overhead compared to using a readily available environment variable. CodeDeploy does not support custom environment variables in the way described. While DEPLOYMENTGROUPID is available, DEPLOYMENTGROUPNAME is more human-readable and directly maps to the desired configuration logic. The Install hook is typically for installing application files, not for pre-configuration like log levels.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed