terraform-provider-google/examples/content-based-load-balancing
Nathan McKinley 114b646fae
Enable 'zone' to be specified at the provider level instead of per-resource. (#816)
- Fetch Zone attribute any place where it *was* being fetched from the schema by
	combination schema / provider-level attribute.
- Allow region to be unspecified if zone is specified.
- Switch one example to using provider-level zone as an example.
- Make provider-level zone optional.  (Individual resources will fail if they can't find a zone.)
- Add tests for getZone and getRegion.
2017-12-06 14:30:04 -08:00
..
scripts provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00
.gitignore provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00
main.tf Enable 'zone' to be specified at the provider level instead of per-resource. (#816) 2017-12-06 14:30:04 -08:00
output.tf provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00
README.md provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00
terraform.tfvars.example provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00
variables.tf provider/google: Google Cloud content-based load balancing example. (#14448) 2017-05-16 13:16:27 -07:00

Content Based Load Balancing in Google Cloud

This provides a template for running an HTTP load balancer that distributes traffic to different instances based on the path in the request URL. It is based on the tutorial at https://cloud.google.com/compute/docs/load-balancing/http/content-based-example.

To start, download your credentials from Google Cloud Console; suggested path for downloaded file is ~/.gcloud/Terraform.json.

Optionally update variables.tf to specify a default value for the project_name variable, and check other variables.

After you run terraform apply on this configuration, it will automatically output the public IP address of the load balancer. After your instance registers, the LB should respond with the following at its root:

<h1>www</h1>

And the following at the /video/ url:

<h1>www-video</h1>

To run, configure your Google Cloud provider as described in

https://www.terraform.io/docs/providers/google/index.html

Run with a command like this:

terraform apply \
	-var="region=us-central1" \
	-var="region_zone=us-central1-f" \
	-var="project_name=my-project-id-123" \
	-var="credentials_file_path=~/.gcloud/Terraform.json" \