Reputation: 1087
I've been struggling with this for hours. So, I created my VPC, along with 4 different subnets. The first three are attached to a regular Internet Gateway. The last one is attached to a NAT Gateway (with 0.0.0.0/0 as Destination). My CodeBuild project is set to use this VPC and the last subnet.
When I click "Validate VPC Settings" in the CodeBuild Project Environment, I get this warning:
"The VPC with ID * might not have an internet connection. CodeBuild cannot find the 0.0.0.0/0 destination for the target internet gateway with subnet ID *."
If I try to run the CodeBuild project, it will timeout because it has no internet access and cannot download sources from CodeCommit...
What am I missing here? The Routing Table for my subnet is attached to the NAT Gateway and the Destination is 0.0.0.0/0, so the error message above doesn't make any sense to me.
Thank you!
Upvotes: 14
Views: 4823
Reputation: 51
For those who did not immediately understand. When you create a NAT, you must select a public network from your VPC and then use that NAT on your private network.
And don't forget to grant the necessary permissions for your codeBuild role. https://docs.aws.amazon.com/codebuild/latest/userguide/auth-and-access-control-iam-identity-based-access-control.html#customer-managed-policies-example-create-vpc-network-interface
Upvotes: 0
Reputation: 1619
I have faced the same issue and below is the fix that I have applied to make it work:
Note: Both the route table must be attached to the same VPC.
Actual output: I got the message "VPC with ID {{vpc-xyz}} has the internet connection".
A reference that has helped to try the above steps: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-internet-connectivity/
I hope this helps.
Upvotes: 2
Reputation: 1087
So, in case anyone else has the same issue, the reason was that I mistakenly placed my NAT Gateway on a private subnet instead of a public one.
Upvotes: 25