CodeDeploy AppSpec File Mapping Rules
A company deploys an application to Amazon EC2 instances. The application runs Amazon Linux 2 and uses AWS CodeDeploy. The application has the following file structure for its code repository: The appspec.yml file has the following contents in the files section: What will the result be for the deployment of the config.txt file? -
- 
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The key insight is that CodeDeploy processes all defined file mappings in order, meaning a specific file can be deployed to multiple locations if it matches multiple mapping rules.
This question tests understanding of AWS CodeDeploy appspec.yml file mapping rules and how multiple entries are processed to determine deployment destinations.
Many learners incorrectly assume that the first matching rule stops further processing or that overlapping paths result in only one destination, leading them to choose option A or C.
Community Discussion (3 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The correct answer is B because AWS CodeDeploy processes each entry in the 'files' section of the appspec.yml independently. The first mapping explicitly copies config/config.txt to /usr/local/src/config.txt. The second mapping copies the entire root directory (/) to /var/www/html, which inherently includes the config/config.txt file at /var/www/html/config/config.txt. Since both rules apply to the target file, it is deployed to both locations.
Why the Other Options Are Wrong
Option A is incorrect because it ignores the second mapping rule that copies the entire repository root. Option C is incorrect because it ignores the specific first mapping rule. Option D is incorrect because there is no mapping rule directing files to /var/www/html/application/web/, and the second rule maps to /var/www/html, not a subdirectory named application/web.
Community Comment Notes
Community consensus strongly supports option B. As user jamesf noted, "The config/config.txt file will be copied to /usr/local/src/config.txt based on the first mapping. Since the entire source directory (/) is also mapped to /var/www/html, config/config.txt will also be copied to /var/www/html/config/config.txt." Similarly, Moumita explained that the second entry copies the entire contents, including the config file, to the specified HTML directory.
Exam Strategy
When analyzing CodeDeploy appspec.yml files, always check every mapping rule for potential overlaps. Remember that specific file mappings do not prevent broader directory mappings from also applying to those same files.
Frequently Asked Questions
Does CodeDeploy stop processing file mappings after the first match?
No, CodeDeploy processes all defined file mappings in the appspec.yml. If a file matches multiple rules, it will be deployed to all specified destinations.
How does the root directory mapping affect specific files?
Mapping the root directory '/' to a destination copies all files and folders from the source root to that destination, including any specific files already targeted by other rules.
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →