smoketurner / serverless-vpc-plugin

Serverless Plugin to create a VPC
MIT License
88 stars 35 forks source link

Add an option for a shared NAT/IP between all zones #4

Closed giladno closed 5 years ago

giladno commented 5 years ago

When using the useNatGateway option, it will create a gateways per zone (so when using 6 zones - it will create 6 gateways + 6 EIP).

Sometimes, we need a limited number of EIP's.

Maybe useNatGateway should be either a boolean or a number, so when using a number it will limit the number of gateways:

useNatGateway: 2
jplock commented 5 years ago

When creating the AppRoute's, I'll just have it cycle between the available NAT gateways. I don't really want to get more complicated than that.

giladno commented 5 years ago

I think that would work!

jplock commented 5 years ago

This is actually more complicated than I thought as we need to ensure each route references a NAT gateway. I might not be able to turn this around very quickly with the US holiday coming up.

giladno commented 5 years ago

Shouldn't it be something similar to this?

   if (useNatGateway) {
        params.NatGatewayId = `NatGateway${index % useNatGateway + 1}`;
      } else {
        params.GatewayId = 'InternetGateway';
      }
jplock commented 5 years ago

Not really. Say you want to deploy in 5 AZ’s but only have 2 NGW’s. We need to create the NGW’s outside of the AZ creation loop and then make sure each AZ alternates between the two NGW’s.

jplock commented 5 years ago

@giladno my apologizes, you were correct. I created #5 to allow specifying the number of the number of NAT Gateways (and EIPs) to provision. Would you mind testing it out by updating your package.json to be:

"serverless-vpc-plugin": "git://github.com/smoketurner/serverless-vpc-plugin.git#jp-gh4

to see if it works for you?