terraform-google-modules / terraform-google-gcloud

Executes Google Cloud CLI commands within Terraform
https://registry.terraform.io/modules/terraform-google-modules/gcloud/google
Apache License 2.0
138 stars 93 forks source link

additional_components null resource exists with not found - wrong shebang #113

Closed grieshaber closed 2 years ago

grieshaber commented 2 years ago

TL;DR

The null resource for additional components uses a local-exec provider. This means, the executed command will be something like bin/sh -c <command>. The script scripts/check_components.sh contains the shebang line #!/bin/bash. Running on images without a bash, but with a sh (like basic alpine images), the command will fail.

Expected behavior

The command script will be exectuted successfully.

Observed behavior

The script exits with exit code 127 - command not found

Terraform Configuration

# pasted from https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/master/dns.tf
module "gcloud_delete_default_kube_dns_configmap" {
  source                      = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
  version                     = "~> 2.1.0"
  enabled                     = (local.custom_kube_dns_config || local.upstream_nameservers_config) && !var.skip_provisioners
  cluster_name                = google_container_cluster.primary.name
  cluster_location            = google_container_cluster.primary.location
  project_id                  = var.project_id
  upgrade                     = var.gcloud_upgrade
  impersonate_service_account = var.impersonate_service_account

  kubectl_create_command  = "${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"
  kubectl_destroy_command = ""

  module_depends_on = concat(
    [google_container_cluster.primary.master_version],
    [for pool in google_container_node_pool.pools : pool.name]
  )
}

Terraform Version

➜  terraform version
Terraform v1.1.3

Additional information

No response

ebrothers-insight commented 2 years ago

Would it be possible to cut a release to bring this change into a tagged version? Other google-hosted modules call this module with a version = "~> 3.1" version constraint, and so it's not possible to bring this change in until a new release is cut.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

mikepietruszka commented 7 months ago

@grieshaber have you had any luck fixing this? I was able to work around it on Alpine by installing bash before running this whatever commands my kubectl-wrapper was running. In my use case kubectl-wrapper was wrapped inside of Cloud Build and Terraform cloud-builder uses Alpine as well.