Question #1042
A developer must cache dependent packages from npmjs, a public package repository, as part of an application’s build pipeline. The build pipeline has an AWS CodeArtifact repository where artifacts of the build are published. The developer needs a solution that requires minimum changes to the build pipeline.
Create a new CodeArtifact domain that contains a new repository that has an external connection to the public package repository.
Modify the CodeArtifact repository resource policy to allow artifacts to be fetched from the public package repository.
Modify the existing CodeArtifact repository to associate an upstream repository with the public package repository.
Create a new CodeArtifact repository that has an external connection to the public package repository.
Explanation
Answer A is correct because AWS CodeArtifact allows repositories to have upstream repositories, which enable dependency resolution from external sources like npmjs. By adding the public repository as an upstream to the existing CodeArtifact repository, the build pipeline can fetch and cache dependencies without requiring changes to the pipeline's configuration (e.g., the repository URL remains the same).
Other options are incorrect because:
- B: Creating a new repository would require updating the pipeline to use the new repository, which adds unnecessary steps.
- C: Creating a new domain and repository is overly complex and also requires pipeline changes.
- D: Resource policies control access permissions, not upstream package sources, so this does not enable caching from npmjs.
Key Points:
1. CodeArtifact repositories can have upstream repositories to pull dependencies from external sources.
2. Associating an upstream minimizes changes since the existing repository is reused.
3. The pipeline continues using the same repository endpoint, avoiding reconfiguration.
Answer
The correct answer is: A