aws / copilot-cli

The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner or Amazon ECS on AWS Fargate.
https://aws.github.io/copilot-cli/
Apache License 2.0
3.52k stars 414 forks source link

[Feature request] Option to reduce the number of NAT Gateway to only one when using placement='private' #3300

Open MasaGon opened 2 years ago

MasaGon commented 2 years ago

SSIA. I want to save money by reducing the number of NAT Gateway.

Lou1415926 commented 2 years ago

The request makes sense to me. Thank you!

In the mean time, would you consider the option to import your own VPC? You can create a NAT Gateway in your VPC and place it in a private subnet, and then route traffic from your private subnets to go through that one NAT Gateway. Please let me know if this works for you!

MasaGon commented 2 years ago

I already did the workaround with CDK and It worked. But I want to do with copilot for future maintenance.

    const vpc = new ec2.Vpc(this, 'VPC', {
      cidr: '10.0.0.0/16',
      natGateways: 1,  // reduce the number of NAT
      subnetConfiguration: [
        { cidrMask: 24, name: 'public', subnetType: ec2.SubnetType.PUBLIC },
        { cidrMask: 24, name: 'private', subnetType: ec2.SubnetType.PRIVATE_WITH_NAT },
      ]
    })
Lou1415926 commented 2 years ago

Hi @MasaGon ! From the CDK snippet that you posted, it looks like there is only one public subnet and one private subnet in your VPC. However, Copilot requires 2 public subnets and/or 2 private subnets when running copilot env init. Would you mind sharing how you used this VPC with Copilot env? This is just a follow-up question for me to understand your use case. Thank you!

matthewhembree commented 1 year ago

This is a good request. I've never had a NAT gateway fail, so I'd even say that 1 could be the default.

lgarvey commented 1 year ago

This would be a useful feature for non production environments. We're looking to migrate an estate with 50+ apps, > 150 environments (vpcs) and the NAT gateway bill will be sizeable.

Ideally we'd like:

3 AZ VPCs with 1 NAT gateway for non production environments and 3 NAT gateways for production.