Create controller instances across zones in the region

* Change controller instances to automatically span zones in a region
* Remove the `zone` required variable
This commit is contained in:
Dalton Hubble
2017-11-05 11:09:03 -08:00
parent 7b38271212
commit 2b0296d671
9 changed files with 15 additions and 16 deletions

View File

@ -14,12 +14,18 @@ resource "google_dns_record_set" "etcds" {
rrdatas = ["${element(google_compute_instance.controllers.*.network_interface.0.address, count.index)}"]
}
# Zones in the region
data "google_compute_zones" "available" {
region = "${var.region}"
status = "UP"
}
# Controller instances
resource "google_compute_instance" "controllers" {
count = "${var.count}"
name = "${var.cluster_name}-controller-${count.index}"
zone = "${var.zone}"
zone = "${element(data.google_compute_zones.available.names, count.index)}"
machine_type = "${var.machine_type}"
metadata {

View File

@ -30,9 +30,9 @@ variable "count" {
description = "Number of controller compute instances the instance group should manage"
}
variable "zone" {
variable "region" {
type = "string"
description = "Google zone that compute instances in the group should be created in (e.g. gcloud compute zones list)"
description = "Google Cloud region (e.g. us-central1, see `gcloud compute regions list`)."
}
variable "machine_type" {