question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VPC with only private subnet fails with error

See original GitHub issue

❓ General Issue

The Question

Because creating a VPC with default settings creates a public and private subnets that default to a NAT gateway for each public subnet, i am running out of EIP. My application doesnt even need a NAT gateways, its just an app that uses dax to connect to dynamodb. Anyways, i tried creating a vpc with just private subnet and add dynamo as a gateway endpoint:

const daxVpc = new Vpc(this, 'daxVpc', {
      cidr: Vpc.DEFAULT_CIDR_RANGE,
      subnetConfiguration: [{
        subnetType: SubnetType.PRIVATE,
        name: defaultSubnetName(SubnetType.PRIVATE)
      }],
      gatewayEndpoints: {
        DYNAMODB: {
          service: GatewayVpcEndpointAwsService.DYNAMODB
        }
      }
    });

but it errors out during deployment:

8/31 | 16:24:34 | CREATE_IN_PROGRESS   | AWS::EC2::Subnet                      | daxVpc/IsolatedSubnet1/Subnet (daxVpcIsolatedSubnet1SubnetA090FC82) Resource creation Initiated
  8/31 | 16:24:34 | CREATE_IN_PROGRESS   | AWS::EC2::Subnet                      | daxVpc/IsolatedSubnet2/Subnet (daxVpcIsolatedSubnet2Subnet469D29C8) Resource creation Initiated
  9/31 | 16:24:34 | CREATE_COMPLETE      | AWS::EC2::RouteTable                  | daxVpc/IsolatedSubnet2/RouteTable (daxVpcIsolatedSubnet2RouteTableE102F846) 
 10/31 | 16:24:34 | CREATE_COMPLETE      | AWS::EC2::RouteTable                  | daxVpc/IsolatedSubnet1/RouteTable (daxVpcIsolatedSubnet1RouteTable5B90AC7F) 
 11/31 | 16:24:36 | CREATE_FAILED        | AWS::EC2::Route                       | daxVpc/IsolatedSubnet1/DefaultRoute (daxVpcIsolatedSubnet1DefaultRoute54F632D7) Exactly one of [EgressOnlyInternetGatewayId, InstanceId, NatGatewayId, TransitGatewayId, GatewayId, VpcPeeringConnectionId, NetworkInterfaceId] must be specified and not empty

What configuration am i missing ??

Environment

  • CDK CLI Version: 1.3.0
  • Module Version: 1.3.0
  • OS:
  • Language: TypeScript

Other information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
harmohan-acommented, Aug 20, 2019

yea, na, that wouldnt work. it needs to connect to dynamo which resides outside the vpc…

just having

const daxVpc = new Vpc(this, 'daxVpc', {
      cidr: Vpc.DEFAULT_CIDR_RANGE,
      // maxAzs: 1
      subnetConfiguration: [{
        subnetType: SubnetType.ISOLATED,
        name: defaultSubnetName(SubnetType.ISOLATED)
      }],
      gatewayEndpoints: {
        DYNAMODB: {
          service: GatewayVpcEndpointAwsService.DYNAMODB
        }
      }
    });

errors out:

There are no ‘Private’ subnets in this VPC. Use a different VPC subnet selection. Subprocess exited with error 1

0reactions
mahmoudabidcommented, Oct 23, 2019

I have a similar issue, where whether using a NAT Gateway or not (i.e specifyng nat_gateways=0 or =1+) will result in a route with destination 0.0.0.0/0 but no target at all:

e.g.

vpc = ec2.Vpc(self, "VPC", 
           cidr=vpc_cidr,
           max_azs=2,
           subnet_configuration=[
                ec2.SubnetConfiguration(
                   name="subnet_group_%s" % i,
                   subnet_type=ec2.SubnetType.PRIVATE)
                for i in range(2)],
           nat_gateways=2,
        )

will create a route as follow for each of the Subnets created, with no target specified:

"VPCsubnetgroup1Subnet1DefaultRoute7E53BA71": {
      "Type": "AWS::EC2::Route",
      "Properties": {
        "RouteTableId": {
          "Ref": "VPCsubnetgroup1Subnet1RouteTableE6131C24"
        },
        "DestinationCidrBlock": "0.0.0.0/0"
      },
      "Metadata": {
       "..."
      }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot connection to an instance in an Amazon VPC
Open the Amazon VPC console. · In the navigation pane, under Virtual Private Cloud, choose Subnets. · In the content pane, select the...
Read more >
AWS CDK Getting Error when try to initialize a new VPC with ...
This is happening because EKS is trying to make the cluster use Private and Public subnets in the VPC, and there are no...
Read more >
Elastic beanstalk deployment in private subnet of the VPC is ...
Elastic beanstalk deployment in private subnet of the VPC is failing with following error when public subnet ACL inbound is deny all ·...
Read more >
API error messages - IBM Cloud Docs
If you are using the CLI, run the command ibmcloud is subnets to list all the subnets for the VPC. Then, run the...
Read more >
My EC2 instance in a private subnet can't connect ... - YouTube
We appreciate your feedback: https://amazonintna.qualtrics.com/jfe/form/SV_a5xC6bFzTcMv35sFind more details in the AWS Knowledge Center: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found