Skip to content

Latest commit

 

History

History

https-redirect

HTTPS Redirect Example

button

This example shows how to enable HTTPS Redirection on Google HTTP/S Loadbalancers.

Change to the example directory

[[ `basename $PWD` != multiple-certs ]] && cd examples/multiple-certs

Install Terraform

  1. Install Terraform if it is not already installed (visit terraform.io for other distributions):

Set up the environment

  1. Set the project, replace YOUR_PROJECT with your project ID:
PROJECT=YOUR_PROJECT
gcloud config set project ${PROJECT}
  1. Configure the environment for Terraform:
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
export GOOGLE_PROJECT=$(gcloud config get-value project)

Run Terraform

terraform init
terraform apply

Testing

  1. Open URL of load balancer in browser:
echo http://$(terraform output load-balancer-ip)

You should see the GCP logo and instance details.

Cleanup

  1. Remove all resources created by terraform:
terraform destroy

Inputs

Name Description Type Default Required
network_name string "tf-lb-https-redirect-nat" no
project string n/a yes
region string "us-east1" no
zone string "us-east1-b" no

Outputs

Name Description
backend_services
load-balancer-ip
load-balancer-ipv6