Skip to content

Commit

Permalink
Use the new "remove_default_node_pool" option.
Browse files Browse the repository at this point in the history
In the provider, #1245 was merged which allows us to remove the default
node pool on cluster creation. Now, we just have to specify the default
node pool name (the one which gets destroyed).

hashicorp/terraform-provider-google#1245
  • Loading branch information
nickcharlton committed May 7, 2018
1 parent f54f37a commit d86de08
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ provider "google" {
}

resource "google_container_cluster" "primary" {
name = "gke-example"
zone = "europe-west2-a"
name = "gke-example"
zone = "europe-west2-a"
remove_default_node_pool = true

/*
node_pool = [{
name = "default-pool"
node_count = 0
}]
*/
node_pool {
name = "default-pool"
}
}

resource "google_container_node_pool" "primary_pool" {
Expand All @@ -35,19 +33,4 @@ resource "google_container_node_pool" "primary_pool" {
auto_repair = true
auto_upgrade = true
}

# Delete the default node pool before spinning this one up
depends_on = ["null_resource.default_cluster_deleter"]
}

resource "null_resource" "default_cluster_deleter" {
provisioner "local-exec" {
command = <<EOF
gcloud container node-pools \
--project terraform-gke \
--quiet \
delete default-pool \
--cluster ${google_container_cluster.primary.name}
EOF
}
}

0 comments on commit d86de08

Please sign in to comment.