Skip to content

Commit

Permalink
fix terraform/gcp bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed Aug 21, 2019
1 parent e17d281 commit d8cdc27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions deploy/modules/gcp/bastion/bastion.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "google_compute_firewall" "allow_ssh_bastion" {
name = "allow-ssh-bastion"
name = "${var.vpc_name}-allow-ssh-bastion"
network = var.vpc_name
project = var.gcp_project

Expand All @@ -13,7 +13,7 @@ resource "google_compute_firewall" "allow_ssh_bastion" {
}

resource "google_compute_firewall" "allow_mysql_from_bastion" {
name = "allow-mysql-from-bastion"
name = "${var.vpc_name}-allow-mysql-from-bastion"
network = var.vpc_name
project = var.gcp_project

Expand All @@ -27,7 +27,7 @@ resource "google_compute_firewall" "allow_mysql_from_bastion" {
}

resource "google_compute_firewall" "allow_ssh_from_bastion" {
name = "allow-ssh-from-bastion"
name = "${var.vpc_name}-allow-ssh-from-bastion"
network = var.vpc_name
project = var.gcp_project

Expand Down
11 changes: 10 additions & 1 deletion deploy/modules/gcp/tidb-cluster/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ data "external" "monitor_port" {
program = ["bash", "-c", "kubectl --kubeconfig ${var.kubeconfig_path} get svc -n ${var.cluster_name} ${var.cluster_name}-grafana -o json | jq '.spec.ports | .[] | select( .name == \"grafana\") | {port: .port|tostring}'"]
}

data "google_compute_zones" "available" {}
locals {
# TODO Update related code when node locations is avaiable in attributes of cluster resource.
cmd_get_cluster_locations = <<EOT
gcloud --project ${var.gcp_project} container clusters list --filter='name=${var.gke_cluster_name}' --format='json[no-heading](locations)' --region ${var.gke_cluster_location} | jq '.[0] | .locations |= join(",")'
EOT
}

data "external" "cluster_locations" {
program = ["bash", "-c", local.cmd_get_cluster_locations]
}
4 changes: 2 additions & 2 deletions deploy/modules/gcp/tidb-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ resource "google_container_node_pool" "monitor_pool" {
}

locals {
num_availability_zones = length(data.google_compute_zones.available.names)
num_availability_zones = length(split(",", data.external.cluster_locations.result["locations"]))
}

module "tidb-cluster" {
Expand All @@ -143,7 +143,7 @@ module "tidb-cluster" {

resource "null_resource" "wait-lb-ip" {
depends_on = [
google_container_node_pool.tidb_pool,
module.tidb-cluster
]
provisioner "local-exec" {
interpreter = ["bash", "-c"]
Expand Down

0 comments on commit d8cdc27

Please sign in to comment.