- Create a new Google Cloud project
- Switch to the new project and open the Cloud Shell
- Clone this repository:
git clone https://github.com/zencore-dev/gcp-outbound-through-external-lb.git
- Change to the directory of this repository:
cd gcp-outbound-through-external-lb
- Run
terraform init
to initialize the Terraform configuration - Run
terraform apply -var "project_id=$GOOGLE_CLOUD_PROJECT" -var "region=us-east1"
to deploy the demo. Change the region to another one if you wish.
- In the Google Cloud Console, go to the Compute Engine -> VM Instances page.
- SSH into the instance named
workload
. - Run
curl https://ifconfig.co
to test the internet access. It will show the external IP address of the Load Balancer. - Run
ping 8.8.8.8
and leave it running. - Shut down the instance named
nat-1
. The ping should still work, as it will fail over to the other NAT instance.
VPC flow logs are enabled for all the subnets, so you can check the logs to see the traffic flow, and observe the failover.
Delete the project that you created in the Google Cloud Console.