Search code examples
amazon-ec2aws-vpc

Unable to access internet from Private subnet | Error: Cannot find a valid baseurl


I am trying to use a NAT Instance rather than a NAT Gateway; I am also not using any Community AMIs for the NAT Instance configuration.

I am trying to do a yum update from my private but I am thrown the following error: Cannot find a valid baseurl for repo: amzn-main/latest

My AWS stack is as follows:

  1. VPC: A VPC VPC1 with an Internet Gateway IGW1 attached.
  2. Subnets: Two subnets - public in us-east-1a and private in us-east-1b.
    1. Public subnet: Subnet1.1-1a has Route table [Public-IGW-1 with local and IGW1 - 0.0.0.0/0].
    2. Private subnet: Subnet1.2-1b has Route table [Private-1 with local and NAT instance NAT EC2 1- 0.0.0.0/0].
  3. Route tables:
    1. Private-1 has routes local and NAT EC2 1 instance - 0.0.0.0/0.
    2. Public-IGW-1 has routes local and IGW1 - 0.0.0.0/0.
  4. Security groups: Subnet-1.1-1a-Public from us-east-1a in VPC1 has SSH MyIP and HTTP with anywhere. Subnet1.1-1a-Private from us-east-1b (have to rename; else deceiving) in VPC1 has inbound 22 - anywhere.
  5. Instances: NAT EC2 1 lives in Subnet1.1-1a of VPC1 with Security group NAT SG inbound 80 - anywhere 22. Private instance has SG - 22 - anywhere. Public instance has SG - 22 - MyIP and 80 - anywhere.

I copied my keypair into the public instance with scp and ssh-ed into the private instance with ssh -i keypair ec2-user@private-ip-addr. When I do a sudo yum update the error canot find a valid baseurl is shown.

I have made sure that NACL is allowing all traffic.


Solution

  • I figured it. The NAT Instance and the Public Instance have to be in the same security groups.