Run example using credentials from gcloud init
This commit is contained in:
parent
af8ef21c54
commit
f0dec4c564
|
@ -2,9 +2,20 @@
|
||||||
|
|
||||||
This provides a template for setting up internal load balancing in Google Cloud. It directly mirrors the tutorial in the [GCP Internal Load Balancing Documentation](https://cloud.google.com/compute/docs/load-balancing/internal/).
|
This provides a template for setting up internal load balancing in Google Cloud. It directly mirrors the tutorial in the [GCP Internal Load Balancing Documentation](https://cloud.google.com/compute/docs/load-balancing/internal/).
|
||||||
|
|
||||||
To run the example, you'll need to [download your credentials from Google Cloud Console](https://www.terraform.io/docs/providers/google/#credentials). A suggested path for the downloaded file is `~/.gcloud/Terraform.json`.
|
To run the example,
|
||||||
|
|
||||||
|
* Log in to gcloud with an account that has permission to create the necessary resources using `gcloud init`.
|
||||||
|
* Optionally update `variables.tf` to specify a default value for the `project_name` variable, and check other variables.
|
||||||
|
* Run with a command like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
terraform apply \
|
||||||
|
-var="region=us-central1" \
|
||||||
|
-var="region_zone=us-central1-b" \
|
||||||
|
-var="region_zone_2=us-central1-c" \
|
||||||
|
-var="project_name=my-project-id-123" \
|
||||||
|
```
|
||||||
|
|
||||||
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
|
After you run `terraform apply` on this configuration, it will
|
||||||
automatically output the internal IP address of the load balancer.
|
automatically output the internal IP address of the load balancer.
|
||||||
|
@ -21,18 +32,3 @@ Using `curl` on the IP address given, the LB should respond with a simple header
|
||||||
```html
|
```html
|
||||||
<!doctype html><html><body><h1>ilb-instance-X</h1></body></html>
|
<!doctype html><html><body><h1>ilb-instance-X</h1></body></html>
|
||||||
```
|
```
|
||||||
|
|
||||||
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-b" \
|
|
||||||
-var="region_zone_2=us-central1-c" \
|
|
||||||
-var="project_name=my-project-id-123" \
|
|
||||||
-var="credentials_file_path=~/.gcloud/Terraform.json"
|
|
||||||
```
|
|
|
@ -1,7 +1,6 @@
|
||||||
provider "google" {
|
provider "google" {
|
||||||
region = "${var.region}"
|
region = "${var.region}"
|
||||||
project = "${var.project_name}"
|
project = "${var.project_name}"
|
||||||
credentials = "${file("${var.credentials_file_path}")}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_network" "my-custom-network" {
|
resource "google_compute_network" "my-custom-network" {
|
||||||
|
|
|
@ -13,8 +13,3 @@ variable "region_zone_2" {
|
||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
description = "The ID of the Google Cloud project"
|
description = "The ID of the Google Cloud project"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "credentials_file_path" {
|
|
||||||
description = "Path to the JSON file used to describe your account credentials"
|
|
||||||
default = "~/.gcloud/Terraform.json"
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue