Skip to content

terraform-google-gcloud does not run on Windows #84

@matthewblain

Description

@matthewblain

The terraform-google-gcloud module does not run on Windows due to a reliance on shell scripts.

Repro

Run, say, terraform plan for a config which uses terraform-google-gcloud.

Result

Error: failed to execute ".terraform/modules/my_rule/scripts/check_env.sh": fork/exec .terraform/modules/my_rule/scripts/check_env.sh: %1 is not a valid Win32 application.

Expected

Terraform to run the gcloud or other command specified in the Terraform config.

The documentation says the requirements are

  • Terraform v0.12
  • Terraform Provider for GCP plugin v2.0
  • curl

All of these run well on Windows, as does the gcloud command line tool.

Proof of concept

It appears to work with these tweaks to main.tf:

  • Commented out data.external.env_override, set download_override to "never" .
  • Changed the run_command local-exec command to be ${self.triggers.create_cmd_entrypoint} ${self.triggers.create_cmd_body}. That is, remove the 'temporary' path part, which caused the command to fail silently.

This demonstrates that the concept works fine on Windows, though of course these changes are not suitable to be committed.

Possible cross-platform fixes

I am a Terraform novice, so take these with a big grain of salt.

  • Instead of check_env shell script, use an env var called, say, TF_VAR_GCLOUD_TF_DOWNLOAD and read it from within Terraform, e.g. ${var.GCLOUD_TF_DOWNLOAD}
  • Instead of check_components shell script, always run gcloud components install.
  • Instead of modifying the path, use (and possibly rename) gcloud_bin_abs_path . Note that if the install cache isn't being used, this prefix would be the empty string "", to use the version on the existing path.

Another possibility would be to create .cmd files parallel to the .sh files.

Alternate or interim solution

Document that a sh interpreter is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4low priority issuesbugSomething isn't workingtriagedScoped and ready for work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions