From 356ed6d9b31648518c450bc5ed3f542f0a043a26 Mon Sep 17 00:00:00 2001 From: Bharath KKB Date: Thu, 28 Jan 2021 17:26:31 -0600 Subject: [PATCH] feat: remove wait for cluster script (#801) * feat: remove wait for cluster script * remove script from all submodules --- autogen/main/cluster.tf.tmpl | 16 ------- autogen/main/outputs.tf.tmpl | 1 - autogen/main/scripts/wait-for-cluster.sh | 44 ------------------- cluster.tf | 16 ------- .../cluster.tf | 16 ------- .../outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- modules/beta-private-cluster/cluster.tf | 16 ------- modules/beta-private-cluster/outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- .../cluster.tf | 16 ------- .../outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- modules/beta-public-cluster/cluster.tf | 16 ------- modules/beta-public-cluster/outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- .../private-cluster-update-variant/cluster.tf | 16 ------- .../private-cluster-update-variant/outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- modules/private-cluster/cluster.tf | 16 ------- modules/private-cluster/outputs.tf | 1 - .../scripts/wait-for-cluster.sh | 44 ------------------- outputs.tf | 1 - scripts/wait-for-cluster.sh | 44 ------------------- test/bundle.hcl | 30 ++++++++++--- 25 files changed, 24 insertions(+), 494 deletions(-) delete mode 100755 autogen/main/scripts/wait-for-cluster.sh delete mode 100755 modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh delete mode 100755 modules/beta-private-cluster/scripts/wait-for-cluster.sh delete mode 100755 modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh delete mode 100755 modules/beta-public-cluster/scripts/wait-for-cluster.sh delete mode 100755 modules/private-cluster-update-variant/scripts/wait-for-cluster.sh delete mode 100755 modules/private-cluster/scripts/wait-for-cluster.sh delete mode 100755 scripts/wait-for-cluster.sh diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index a24adc9b8..4861038e2 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -602,19 +602,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/autogen/main/outputs.tf.tmpl b/autogen/main/outputs.tf.tmpl index 83ee4a3bb..da7ded33b 100644 --- a/autogen/main/outputs.tf.tmpl +++ b/autogen/main/outputs.tf.tmpl @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/autogen/main/scripts/wait-for-cluster.sh b/autogen/main/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/autogen/main/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/cluster.tf b/cluster.tf index 09850eff0..0361d4b76 100644 --- a/cluster.tf +++ b/cluster.tf @@ -320,19 +320,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index 6a3d03448..a3e8dbc05 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -555,19 +555,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/beta-private-cluster-update-variant/outputs.tf b/modules/beta-private-cluster-update-variant/outputs.tf index c294fc9ef..c707199d6 100644 --- a/modules/beta-private-cluster-update-variant/outputs.tf +++ b/modules/beta-private-cluster-update-variant/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 5a5fe1e7b..05fad5ddc 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -470,19 +470,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/beta-private-cluster/outputs.tf b/modules/beta-private-cluster/outputs.tf index c294fc9ef..c707199d6 100644 --- a/modules/beta-private-cluster/outputs.tf +++ b/modules/beta-private-cluster/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/beta-private-cluster/scripts/wait-for-cluster.sh b/modules/beta-private-cluster/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/beta-private-cluster/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 09051e8f7..ae9b1d75b 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -536,19 +536,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/beta-public-cluster-update-variant/outputs.tf b/modules/beta-public-cluster-update-variant/outputs.tf index bd3cc8be1..feebc9905 100644 --- a/modules/beta-public-cluster-update-variant/outputs.tf +++ b/modules/beta-public-cluster-update-variant/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index c580bef1a..792f647ad 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -451,19 +451,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/beta-public-cluster/outputs.tf b/modules/beta-public-cluster/outputs.tf index bd3cc8be1..feebc9905 100644 --- a/modules/beta-public-cluster/outputs.tf +++ b/modules/beta-public-cluster/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/beta-public-cluster/scripts/wait-for-cluster.sh b/modules/beta-public-cluster/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/beta-public-cluster/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index ce0c42e25..ba567832f 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -418,19 +418,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/private-cluster-update-variant/outputs.tf b/modules/private-cluster-update-variant/outputs.tf index 8b80afa0b..1bb6d92dd 100644 --- a/modules/private-cluster-update-variant/outputs.tf +++ b/modules/private-cluster-update-variant/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index ee8c7a931..838f3a054 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -333,19 +333,3 @@ resource "google_container_node_pool" "pools" { } } -module "gcloud_wait_for_cluster" { - source = "terraform-google-modules/gcloud/google" - version = "~> 2.0.2" - enabled = ! var.skip_provisioners - upgrade = var.gcloud_upgrade - - create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" - - module_depends_on = concat( - [google_container_cluster.primary.master_version], - [for pool in google_container_node_pool.pools : pool.name] - ) -} diff --git a/modules/private-cluster/outputs.tf b/modules/private-cluster/outputs.tf index 8b80afa0b..1bb6d92dd 100644 --- a/modules/private-cluster/outputs.tf +++ b/modules/private-cluster/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/modules/private-cluster/scripts/wait-for-cluster.sh b/modules/private-cluster/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/modules/private-cluster/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/outputs.tf b/outputs.tf index d0342cefa..d6df34d8c 100644 --- a/outputs.tf +++ b/outputs.tf @@ -54,7 +54,6 @@ output "endpoint" { */ google_container_cluster.primary, google_container_node_pool.pools, - module.gcloud_wait_for_cluster.wait, ] } diff --git a/scripts/wait-for-cluster.sh b/scripts/wait-for-cluster.sh deleted file mode 100755 index 12543f336..000000000 --- a/scripts/wait-for-cluster.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -# shellcheck disable=SC2034 -if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then - export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}" -fi - -PROJECT=$1 -CLUSTER_NAME=$2 -CLUSTER_LOCATION=$3 -IMPERSONATE_SERVICE_ACCOUNT=$4 - -echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." - -while - # if cluster location is set, use it in filter - if [ -z "${CLUSTER_LOCATION}" ]; then - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - else - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") - fi - if [ -z "${current_status}" ]; then - echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" - exit 1 - fi - [[ "${current_status}" != "RUNNING" ]] -do printf ".";sleep 5; done - -echo "Cluster is ready!" diff --git a/test/bundle.hcl b/test/bundle.hcl index da8610d25..dd8b451cf 100644 --- a/test/bundle.hcl +++ b/test/bundle.hcl @@ -3,10 +3,28 @@ terraform { } providers { - google = ["~> 3.42.0"] - google-beta = ["~> 3.42.0"] - external = ["~> 1.0"] - kubernetes = ["~> 1.12.0"] - null = ["~> 2.0"] - random = ["~> 2.0"] + google = { + version = "~> 3.42.0" + source = "hashicorp/google" + } + google-beta = { + version = "~> 3.49.0" + source = "hashicorp/google-beta" + } + external = { + version = "~> 1.0" + source = "hashicorp/external" + } + kubernetes = { + version = "~> 1.12.0" + source = "hashicorp/kubernetes" + } + null = { + version = "~> 2.0" + source = "hashicorp/null" + } + random = { + version = "~> 2.0" + source = "hashicorp/random" + } }