Adds monitoring behind an https lb.
Showing
resource "google_compute_address" "static-ip-address" { | ||
count = "${var.node_count}" | ||
name = "${format("%v-%02d-%v-%v-static-ip", var.name, count.index + 1 + 100, var.tier, var.environment)}" | ||
address_type = "INTERNAL" | ||
address = "${replace(var.ip_cidr_range, "/\\d+\\/\\d+$/", count.index + 1 + 100)}" | ||
subnetwork = "${google_compute_subnetwork.subnetwork.self_link}" | ||
} | ||
resource "google_compute_disk" "data_disk" { | ||
project = "${var.project}" | ||
count = "${(var.attach_data_disk && var.node_count > 0) ? var.node_count : 0}" | ||
name = "${format("%v-%02d-%v-%v-data", var.name, count.index + 1, var.tier, var.environment)}" | ||
zone = "${var.zone != "" ? var.zone : data.google_compute_zones.available.names[(count.index + 1) % length(data.google_compute_zones.available.names)]}" | ||
size = "${var.data_disk_size}" | ||
type = "${var.data_disk_type}" | ||
labels { | ||
environment = "${var.environment}" | ||
pet_name = "${var.name}" | ||
} | ||
} | ||
resource "google_compute_instance" "instance_with_attached_disk" { | ||
count = "${var.attach_data_disk ? var.node_count : 0}" | ||
name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}" | ||
machine_type = "${var.machine_type}" | ||
metadata = { | ||
"CHEF_URL" = "${var.chef_provision.["server_url"]}" | ||
"CHEF_VERSION" = "${var.chef_provision.["version"]}" | ||
"CHEF_NODE_NAME" = "${format("%v-%02d.%v.%v.%v", var.name, count.index + 1, var.tier, var.environment, var.dns_zone_name)}" | ||
"CHEF_ENVIRONMENT" = "${var.environment}" | ||
"CHEF_RUN_LIST" = "${var.chef_run_list}" | ||
"CHEF_DNS_ZONE_NAME" = "${var.dns_zone_name}" | ||
"CHEF_PROJECT" = "${var.project}" | ||
"GL_PERSISTENT_DISK_PATH" = "${var.persistent_disk_path}" | ||
} | ||
metadata_startup_script = "${file("${path.module}/../../../scripts/google/bootstrap-v${var.bootstrap_version}.sh")}" | ||
project = "${var.project}" | ||
zone = "${var.zone != "" ? var.zone : data.google_compute_zones.available.names[(count.index + 1) % length(data.google_compute_zones.available.names)]}" | ||
service_account { | ||
// this should be the instance under which the instance should be running, rather than the one creating it... | ||
email = "[email protected]" | ||
// all the defaults plus cloudkms to access kms | ||
scopes = [ | ||
"https://www.googleapis.com/auth/cloud.useraccounts.readonly", | ||
"https://www.googleapis.com/auth/devstorage.read_only", | ||
"https://www.googleapis.com/auth/logging.write", | ||
"https://www.googleapis.com/auth/monitoring.write", | ||
"https://www.googleapis.com/auth/pubsub", | ||
"https://www.googleapis.com/auth/service.management.readonly", | ||
"https://www.googleapis.com/auth/servicecontrol", | ||
"https://www.googleapis.com/auth/trace.append", | ||
"https://www.googleapis.com/auth/cloudkms", | ||
"https://www.googleapis.com/auth/compute.readonly", | ||
] | ||
} | ||
scheduling { | ||
preemptible = "${var.preemptible}" | ||
} | ||
boot_disk { | ||
auto_delete = true | ||
initialize_params { | ||
image = "${var.os_boot_image}" | ||
size = "${var.os_disk_size}" | ||
type = "${var.os_disk_type}" | ||
} | ||
} | ||
attached_disk { | ||
source = "${google_compute_disk.data_disk.*.self_link[count.index]}" | ||
} | ||
network_interface { | ||
subnetwork = "${google_compute_subnetwork.subnetwork.name}" | ||
address = "${google_compute_address.static-ip-address.*.address[count.index]}" | ||
access_config = {} | ||
} | ||
labels { | ||
environment = "${var.environment}" | ||
pet_name = "${var.name}" | ||
} | ||
tags = [ | ||
"${var.name}", | ||
"${var.environment}", | ||
] | ||
provisioner "local-exec" { | ||
when = "destroy" | ||
command = "knife node delete ${format("%v-%02d.%v.%v.%v", var.name, count.index + 1, var.tier, var.environment, var.dns_zone_name)} -y; knife client delete ${format("%v-%02d.%v.%v.%v", var.name, count.index + 1, var.tier, var.environment, var.dns_zone_name)} -y; exit 0" | ||
} | ||
} |
Please register or sign in to comment