Multi-Cloud VPN and Multi-Zone Subnetworks — Network Setup for Multi-Cloud Database Deployments

A tutorial for setting up a multi-cloud VPN

Christoph Bussler
Google Cloud - Community
13 min readAug 10, 2020

--

Introduction

This blog is a tutorial on how to set up a VPN between Google Cloud and AWS, create multi-zone subnetworks in each cloud and test any-to-any connectivity. For part of the setup this blog follows the community tutorial Google Cloud HA VPN interoperability guide for AWS and cites verbatim from it. This blog goes beyond the content of the community tutorial and includes setting up subnetworks as well as perform any-to-any testing of the network setup.

Please note upfront that this is a step-by-step manual setup all the way in case you want to understand and to execute all the steps required yourself. If you are looking for an automatic setup, this blog is not for you. A post setting up a VPN using only using user interfaces is here, for example.

Setup phases

This blog divides up the setup into the following phases:

  • Project setup. Create a project in Google Cloud and create a project in AWS. This is not further explained here — the instructions assume you have one project in each cloud setup and that you have the permissions to set up VPNs, subnets, firewall rules, compute engines, and additional resources as needed.
  • VPN configuration. The initial setup phase is setting up a VPN between Google Cloud and AWS. This is a step-by-step set of instructions.
  • Subnet configuration. The next phase is setting up subnets as well as firewalls and security settings.
  • Testing. The final phase is testing of the setup by creating VMs in Google Compute Engine as well as EC2 for any-to-any ping testing.

After a successful testing phase the network setup is ready as network setup for multi-cloud use cases and workloads.

Notation

On the Google Cloud side glcoud commands are shown. Variable values that you have to select are denoted as […]. They are introduced as needed at the first time of use. You could replace those variables consistently by a global text replace in order to prepare all commands consistently.

On the AWS side user interface instructions are provided and are mostly taken verbatim from Google Cloud HA VPN interoperability guide for AWS with sometimes small modifications (for clarification) that are explicitly marked as [[...]].

It is recommended that you note down all chosen values of variables as well as names/values as typed into the various user interfaces to keep a record of the details. Here is one example of this approach: Configuration parameters and values. Another approach is creating a spreadsheet where you record all settings and variable values.

VPN configuration

In the Google Cloud project

  • Create a network (GCP: Google Cloud Platform):
  • As a best practice, delete the default network in the project. This deletion is not required, but prevents accidental configuration of the incorrect network. You might have to delete several firewall rules first if the Cloud Shell indicates that:
  • Add two subnets:
  • Add a VPN gateway:
  • Add a router:

In the AWS project

Note: Additions or modifications of mine in cited text are indicated by [[...]] so that any deviation from Google Cloud HA VPN interoperability guide for AWS is explicitly marked.

  • Create a VPC with default tenancy
  • Create an AWS [[virtual private]] gateway and attach it to the VPC:
  • Create a site-to-site connection and customer gateway:
  • Create the second site-to-site connection (the cited text states also to create a second AWS Gateway, but that is impossible. So I added [[not:...]] to indicate that this should not be done):
  • Download the AWS configuration settings for each site-to-site connection:

In the Google Cloud project

Create an external VPN gateway resource (also called Peer VPN Gateway) as follows.

When you create a GCP external VPN gateway resource for an AWS virtual private gateway, you must create it with four interfaces, as shown in the AWS topology diagram [[in here: Google Cloud HA VPN interoperability guide for AWS]].

Note: For successful configuration, you must use the public IP addresses for the AWS interfaces as referenced in the two AWS configuration files you downloaded earlier. You must also match each AWS public IP address exactly with a specific HA VPN interface. The instructions below describe this task in detail.

Use the following command to create the External VPN gateway resource. Replace the options as noted below:

  • Create VPN tunnels on the HA VPN gateway

Create four VPN tunnels, two for each interface, on the HA VPN gateway created previously.

In the following commands to create each tunnel, replace the options as noted in the configuration below:

  • Create the tunnel to AWS Connection 0, IP address 0:
  • Create the tunnel to AWS Connection 0, IP address 1
  • Create the tunnel to AWS Connection 1, IP address 0
  • Create the tunnel to AWS Connection 1, IP address 1
  • Assign BGP IP addresses

Follow the instructions below to assign BGP IP addresses to Cloud Router interfaces and to BGP peer interfaces.

For each VPN tunnel, get the BGP IP addresses and ASNs for both AWS and GCP from the AWS configuration files you downloaded earlier.

Replace the options for the GCP side as noted below:

  • Replace the options for the AWS side as noted below:
  • [[For]] [AWS_PEER_ASN] Use the following ASNs under BGP subsection #4 (currently the ASN is the same in all four cases):
  • Check the status:

At this point we stop following Google Cloud HA VPN interoperability guide for AWS as that tutorial does not set up subnetworks, VMs or firewall rules for multi-zone subnetworks and any-to-any ping testing across those.

In the AWS project

  • In the AWS console under VIRTUAL PRIVATE CLOUD in the section Route Tables:

Subnet configuration

In the AWS project

In AWS subnets are zonal resources, whereas in Google Cloud subnets are regional resources. For an HA deployment, in Google Cloud one subnet is required as all zones in that region are covered. In AWS, each zone in a region needs its own subnet for resources in that zone.

  • Create a subnet for each zone in the region of the AWS project (if you want coverage of all zones). In section Subnets:

In order to test connectivity:

In addition, an Internet Gateway is needed: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html.

  • Create an internet gateway. In section Internet Gateways:
  • In Route Tables:

To allow the AWS EC2 instances to ping each other, the AWS security group requires ingress rules so that ingress from all subnets is allowed. Once you added the ingress rules for the subnets, you can ping each of the instances from each instance using their private IP addresses. For the ping ICMP ingress is sufficient.

To allow the GCP VM instances to ping the AWS EC2 instances, on the AWS security group for the EC2 instances, two ingress rules are to be added, one for each Google Cloud subnetwork.

In total there should be several ingress rules in the security group:

  • One each for every AWS subnet
  • One each for every GCP subnet
  • One for your laptop to access the AWS EC2 VMs

At this point you can ssh into the EC2 instances you created and ping each from the other.

In the Google Cloud project

Two subnets in two different regions were created above. This setup allows resources in two regions to interact with each other in order to e.g. implement a disaster recovery strategy.

  • The following firewall rules have to be implemented in order to allow resource communication:

One way to test connectivity right away is to create a VM in each of the two regions, and have them ping each other. If that works, the firewall rules are set up correctly.

Testing

At this point you have ideally configured:

  • one VM in each of the GCP subnetworks
  • one VM in each of the AWS subnetworks

From a testing perspective each VM should be able to ping itself and each of the other VMs, in Google Cloud as well as AWS (aka, complete mesh reachability).

Other connectivity options

VPN is not the only connectivity option. Depending on the requirements, especially bandwidth and performance, alternatives exist to VPN. See this blog Connecting to Google Cloud: your networking options explained as well as this page Google Cloud Hybrid Connectivity for details and decision trees.

Summary

The instructions above

  • setup a VPN between Google Cloud and AWS
  • created a subnet in each of two regions in Google Cloud
  • created one or more subnets in different AWS regions based on your choice
  • tested the connectivity with VMs in Google Cloud and AWS.

At this point you have a multi-cloud, multi-region and multi-zone setup. You can deploy additional resources into the subnetworks. If you need additional network protocols between the resources, do not forget to setup firewall rules accordingly.

Acknowledgements

I’d like to thank Anibal Santiago (Anibal Santiago) for the thorough review and many comments to improve the accuracy of this content.

Disclaimer

Christoph Bussler is a Solutions Architect at Google, Inc. (Google Cloud). The opinions stated here are my own, not those of Google, Inc.

--

--