CodeDeploy AppSpec File Mapping Rules

Answer Correct answer: B — The config.txt file will be deployed to /usr/local/src/config.txt and to /var/www/html/config/config.txt.

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? - image - image

  1. The config.txt file will be deployed to only /var/www/html/config/config.txt.
  2. The config.txt file will be deployed to /usr/local/src/config.txt and to /var/www/html/config/config.txt. Correct Answer
  3. The config.txt file will be deployed to only /usr/local/src/config.txt.
  4. The config.txt file will be deployed to /usr/local/src/config.txt and to /var/www/html/application/web/config.txt.

Community Votes

B
100%

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)

jamesf 👍 4 Selected: B
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.
Moumita 👍 4 Selected: B
First Entry: source: config/config.txt destination: /usr/local/src/config.txt This rule specifically copies the config/config.txt file from the source repository to /usr/local/src/config.txt on the EC2 instance. Second Entry: source: / destination: /var/www/html This rule copies the entire contents of the root directory of the repository to /var/www/html on the EC2 instance. This includes the config/config.txt file, so it will be copied to /var/www/html/config/config.txt. Given these two rules: The config/config.txt file will be copied to /usr/local/src/config.txt by the first rule. The same file will also be copied to /var/www/html/config/config.txt due to the second rule. So, the correct answer is indeed B. The config.txt file will be deployed to /usr/local/src/config.txt and to /var/www/html/config/config.txt.
tgv 👍 4 Selected: B
---> B

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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 →

← Back to DOP-C02 Study Guide