Issues running sample code in Google Cloud Build
Closed this issue · 2 comments
Terraform Version
$ terraform -v
Terraform v1.0.7
on linux_amd64
- provider registry.terraform.io/hashicorp/google v3.84.0
- provider registry.terraform.io/hashicorp/google-beta v3.84.0
Terraform Configuration File:
module "gcloud" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0"
platform = "linux"
additional_components = ["kubectl", "beta"]
create_cmd_entrypoint = "gcloud"
create_cmd_body = "version"
destroy_cmd_entrypoint = "gcloud"
destroy_cmd_body = "version"
}
Expected Behavior
When I execute this code using Google's Cloud Build, I expect to see the output of the gcloud versions. I confirmed this code is executing successfully in Google's Cloud Shell.
Actual Behavior
I receive the following error in Cloud Build:
module.gcloud.null_resource.additional_components[0]: Creating...
module.gcloud.null_resource.additional_components[0]: Provisioning with 'local-exec'...
module.gcloud.null_resource.additional_components[0] (local-exec): Executing: ["/bin/sh" "-c" ".terraform/modules/gcloud/scripts/check_components.sh gcloud kubectl,beta"]
module.gcloud.null_resource.additional_components[0] (local-exec): /bin/sh: .terraform/modules/gcloud/scripts/check_components.sh: not found
╷
│ Error: local-exec provisioner error
│
│ with module.gcloud.null_resource.additional_components[0],
│ on .terraform/modules/gcloud/main.tf line 174, in resource "null_resource" "additional_components":
│ 174: provisioner "local-exec" {
│
│ Error running command
│ '.terraform/modules/gcloud/scripts/check_components.sh gcloud
│ kubectl,beta': exit status 127. Output: /bin/sh:
│ .terraform/modules/gcloud/scripts/check_components.sh: not found
If I comment out the additional_components argument, I receive a different error:
module.gcloud.null_resource.additional_components[0]: Destroying... [id=3683393589026923643]
module.gcloud.null_resource.additional_components[0]: Destruction complete after 0s
module.gcloud.null_resource.run_command[0]: Creating...
module.gcloud.null_resource.run_destroy_command[0]: Creating...
module.gcloud.null_resource.run_destroy_command[0]: Creation complete after 0s [id=3140166281657363380]
module.gcloud.null_resource.run_command[0]: Provisioning with 'local-exec'...
module.gcloud.null_resource.run_command[0] (local-exec): Executing: ["/bin/sh" "-c" "PATH=/google-cloud-sdk/bin:$PATH\ngcloud version\n"]
module.gcloud.null_resource.run_command[0] (local-exec): /bin/sh: gcloud: not found
╷
│ Error: local-exec provisioner error
│
│ with module.gcloud.null_resource.run_command[0],
│ on .terraform/modules/gcloud/main.tf line 231, in resource "null_resource" "run_command":
│ 231: provisioner "local-exec" {
│
│ Error running command 'PATH=/google-cloud-sdk/bin:$PATH
│ gcloud version
│ ': exit status 127. Output: /bin/sh: gcloud: not found
Update
I installed curl on my Alpine Linux container and I set skip_download to "false." However, I'm still getting the error "(local-exec): /bin/sh: curl: not found":
module.gcloud.random_id.cache[0]: Creating...
module.gcloud.random_id.cache[0]: Creation complete after 0s [id=OHpoXw]
module.gcloud.null_resource.prepare_cache[0]: Creating...
module.gcloud.null_resource.upgrade_destroy[0]: Creating...
module.gcloud.null_resource.prepare_cache[0]: Provisioning with 'local-exec'...
module.gcloud.null_resource.prepare_cache[0] (local-exec): Executing: ["/bin/sh" "-c" "mkdir -p .terraform/modules/gcloud/cache/387a685f"]
module.gcloud.null_resource.upgrade_destroy[0]: Creation complete after 0s [id=8477726944587680442]
module.gcloud.null_resource.prepare_cache[0]: Creation complete after 0s [id=7966150516894765805]
module.gcloud.null_resource.download_jq[0]: Creating...
module.gcloud.null_resource.decompress_destroy[0]: Creating...
module.gcloud.null_resource.download_jq[0]: Provisioning with 'local-exec'...
module.gcloud.null_resource.download_jq[0] (local-exec): Executing: ["/bin/sh" "-c" "curl -sL -o .terraform/modules/gcloud/cache/387a685f/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x .terraform/modules/gcloud/cache/387a685f/jq"]
module.gcloud.null_resource.download_gcloud[0]: Creating...
module.gcloud.null_resource.download_jq[0] (local-exec): /bin/sh: curl: not found
module.gcloud.null_resource.decompress_destroy[0]: Creation complete after 0s [id=5679931229079268092]
module.gcloud.null_resource.download_gcloud[0]: Provisioning with 'local-exec'...
module.gcloud.null_resource.download_gcloud[0] (local-exec): Executing: ["/bin/sh" "-c" "curl -sL -o .terraform/modules/gcloud/cache/387a685f/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-281.0.0-linux-x86_64.tar.gz"]
module.gcloud.null_resource.download_gcloud[0] (local-exec): /bin/sh: curl: not found
╷
│ Error: local-exec provisioner error
│
│ with module.gcloud.null_resource.download_gcloud[0],
│ on .terraform/modules/gcloud/main.tf line 103, in resource "null_resource" "download_gcloud":
│ 103: provisioner "local-exec" {
│
│ Error running command 'curl -sL -o
│ .terraform/modules/gcloud/cache/387a685f/google-cloud-sdk.tar.gz
│ https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-281.0.0-linux-x86_64.tar.gz':
│ exit status 127. Output: /bin/sh: curl: not found
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