A software development team configures an AWS CodeBuild project to run within a private subnet of a VPC to perform integration testing against an Amazon RDS DB instance. The integration tests connect to the database successfully, but the build project fails during the install phase when running commands to retrieve packages from a public software registry. Which of the following actions will resolve this build failure?
- Configure a NAT gateway in a public subnet of the VPC, and update the private subnet's route table to route outbound internet traffic through the NAT gateway.Answer
- BAttach a VPC endpoint for AWS Systems Manager to the VPC, and reference the external dependency parameters under the secrets-manager block of the buildspec file.
- CUpdate the trust policy of the AWS CodeBuild service role to allow the VPC's route table to assume the role during the build execution.
- DPlace the buildspec.yml file in the subdirectory that contains the integration test suites to align execution scopes.
Answer
Configure a NAT gateway in a public subnet of the VPC, and update the private subnet's route table to route outbound internet traffic through the NAT gateway.
The correct answer is to configure a NAT gateway in a public subnet of the VPC and update the private subnet's route table. When AWS CodeBuild projects are configured to run inside a VPC, they do not have direct internet access. If the build needs to access both private resources (such as Amazon RDS) and public registries to pull dependencies, you must place the CodeBuild project in private subnets, configure a NAT gateway in a public subnet, and route outbound internet traffic (0.0.0.0/0) through that NAT gateway.
Step-by-Step Solution
Key Concept
AWS CodeBuild VPC connectivity and internet access requirements
Estimated Time:1m 30s