A development team has configured an AWS CodeBuild project to run inside a private subnet of a VPC. During the build execution, the project fails because it cannot download external package dependencies from the internet. Additionally, subsequent runs are taking a long time because the dependencies are fully downloaded from scratch each time. Which two actions should the developer take to resolve the internet connectivity issue and speed up the builds? (Select TWO.)
- Configure a NAT gateway in a public subnet of the VPC, and update the private subnet's route table to route traffic through the NAT gateway.Answer
- Enable local dependency caching in the CodeBuild project settings, and specify the package manager's cache directory in the `cache` section of the `buildspec.yml` file.Answer
- CMove the `buildspec.yml` file into a subdirectory named `.ebextensions` at the root of the source directory to automatically enable caching.
- DAdd a trust policy to the CodeBuild service role that explicitly allows Systems Manager Parameter Store to assume the role and push cached dependencies.
- EConfigure AWS Secrets Manager to store the compiled dependency binaries as secrets to enable automatic encryption and rotation between builds.
Answer
Configure a NAT gateway in a public subnet of the VPC, update the private subnet's route table to route traffic through the NAT gateway, enable local dependency caching in CodeBuild, and define the cache directories in the cache section of the buildspec file.
To resolve the issues, the developer must configure a NAT gateway in a public subnet and route outbound traffic from the private subnet to it. This provides the necessary internet access for CodeBuild to download external dependencies. Additionally, the developer must enable local caching in CodeBuild and define the target cache paths in the buildspec file. This ensures that dependencies are reused across builds instead of being downloaded from scratch.
Step-by-Step Solution
Key Concept
AWS CodeBuild VPC network routing and local dependency caching configurations