How to do it...

Initially, the instances in the subnets created will not have connectivity. We'll setup a VPN connection and verify that we are able to establish a connection between the instances in the two separate networks:

  1. Let's create a VM in the subnet alpha-subnet-vpn with default attributes:
gcloud beta compute instances create "alpha-instance" --zone"us-east1-c" --machine-type "n1-standard-1" --subnet"alpha-subnet-vpn" --image "debian-9-stretch-v20171213"--image-project "debian-cloud"
  1. Similarly, let's create another VM in the beta-subnet-vpn:
gcloud beta compute instances create "beta-instance" --zone"us-central1-c" --machine-type "n1-standard-1" --subnet"beta-subnet-vpn" --image "debian-9-stretch-v20171213"--image-project "debian-cloud" ...

Get Building Google Cloud Platform Solutions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.