aws / aws/apprunner-roadmap

Custom VPC with outgoing connections to the internet is complicated to set up

Open
#192 21 comments 108 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
301
Forks
15
PR merge metrics
No merged PRs in 30d

Description

**Community Note**
* Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do * not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment

Selecting custom VPC for outgoing network traffic makes outgoing connections to the internet fail despite the VPC in question having an internet gateway configured. The need for a NAT Gateway is explained [in the documentation](https://docs.aws.amazon.com/apprunner/latest/dg/network-vpc.html#network-vpc.considerations-subnet). An example of exactly how it needs to be configured would be nice but even nicer would be not having to worry about it at all and just have an option to retain outbound connectivity despite having a VPC connection to e.g. a database in RDS.

For our very basic use case ([similar to this](https://github.com/aws/apprunner-roadmap/issues/141)): an application with a database connection and the ability to connect to the internet, this is not the case and we're left with these suboptimal options:

* Configure the NAT Gateway
- Complicated to set up and maintain
- A little bit [costly](https://aws.amazon.com/vpc/pricing/) (~ $90 / month [for a basic 3 AZ setup + extra cost for traffic](https://github.com/aws/apprunner-roadmap/issues/109#issuecomment-1358069302))
* Use the default outgoing network traffic configuration
- This requires that the DB accepts connections from the internet and we lose the added security of the VPC

The reason we're using AppRunner is to avoid having to configure VPC, Subnets, Route Tables, Security Groups, ACLs, NAT Gateways etc. and this rather basic use case of having both db and outbound connectivity requires us to do exactly that.

### How we configured the NAT Gateway to get outbound internet connections working
* Create a new VPC in the console
- Use the _VPC and more_ option
- @jedwardblack: be sure to [leave both DNS Options checked (Enable DNS hostnames & Enable DNS resolution)](https://github.com/aws/apprunner-roadmap/issues/192#issuecomment-1890471823)
- We selected Number of Availability Zones: 2 and NAT gateways in 1 AZ to minimise costs during testing
- This creates the Nat Gateway(s) and required Subnets and Route tables for you. In our case 2 private and 2 public subnets are created and by default the public subnets are connected to the internet gateway and the private subnets are connected to the NAT Gateway(s)
* Move the database to the new VPC
- In the RDS console create a Subnet group with the private subnets that were created a moment ago
- If you need to connect to the DB from the outside, also add a *single* public subnet (and a security group that allows access from your IP address). Note: adding multiple public subnets seem to break the configuration.
- RDS > Select instance > Modify > DB Subnet group > Select newly created Subnet group
- Select Apply immediately and then Modify DB instance
- Wait for the database status to turn back to available before testing
* Create a new VPC connector in the App Runner console Configuration > Networking tab > Outgoing section
- Select the newly created VPC and **only** the private subnets
- Wait for the changes to get deployed before testing

**Tell us about your request**
What do you want us to build?

An option to keep outgoing internet connectivity while also connecting to a database instance in RDS via a VPC without going through the tedious process of setting up NAT Gateways and the bits and bobs that they require in order to work.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.