If I want to have public and isolated subnets in my VPC, but no private subnets, I cannot use the default VPC construct to do so. I get an error:
Vpc testvpc = new Vpc(this, "testVPC", VpcProps.builder()
.natGateways(0)
.build());
Error: If you do not want NAT gateways (natGateways=0), make sure you don't configure any PRIVATE subnets in 'subnetConfiguration' (make them PUBLIC or ISOLATED instead)
To work around this issue, I have to specify a custom subnet configuration, 1 Public and 1 Isolated per subnet:
Vpc testvpc = new Vpc(this, "testVPC", VpcProps.builder()
.subnetConfiguration(
Arrays.asList(
SubnetConfiguration.builder()
.subnetType(SubnetType.PUBLIC)
.name("public")
.build(),
SubnetConfiguration.builder(
.subnetType(SubnetType.ISOLATED)
.name("isolated").build()
))
.natGateways(0)
.build());
I would like the default to be 1 Public, 1 Isolated when zero natGatways are specified.
This is a nice-to-have, as there is a workaround.
This should just work:
Vpc testvpc = new Vpc(this, "testVPC", VpcProps.builder()
.natGateways(0)
.build());
This is a :rocket: Feature Request
I see what you're saying, but I'm not sure this would be expected behavior for most people. I'm not opposed to the change though, if you can rustle up enough community support for this change.
It will be waiting for upvotes on this request.
Just to make sure I understand: This means no private subnet, no NAT Gateway and no NAT costs on the VPC, right? I think that's what I'm looking for.
Just to make sure I understand: This means no private subnet, no NAT Gateway and no NAT costs on the VPC, right? I think that's what I'm looking for.
I intended it to be Public Subnets and Isolated Subnets. If you specify 1 NAT gateway but 6 AZs, you still get 6 Public/6 Private subnets, but there is only one NAT gateway in one of the Public subnets.
The intent is that, by specifying 0, you still get 6 Public/6 Private, but with 0 NAT Gateways, which effectively gives you 6 Public/6 Isolated
Currently the behavior is:
As far as I can tell, you want the behavior to be:
The latter can only work if you DON'T provide any subnet configuration, in which it just leads to picking a different "default" configuration. I guess it's feasible, and I would accept it if someone submitted it as a PR.
Most helpful comment
Just to make sure I understand: This means no private subnet, no NAT Gateway and no NAT costs on the VPC, right? I think that's what I'm looking for.