terraform-google-gcloud icon indicating copy to clipboard operation
terraform-google-gcloud copied to clipboard

platform default to linux

Open bdelv opened this issue 5 years ago • 4 comments

When used indirectly (like when creating a project using terraform-google-project-factory), the platform variable of the gcloud module is not accessible, so its default to linux is problematic if using a mac (yes, docker is better, but still :) ).

some ideas:

  • skip_download could be renamed to something like skip_download_if_gcloud_found and defaulted to true
  • there could be an attempt to detect the OS if the platform is empty (default "") with something like:
if [[ $(uname -s) == "Darwin" ]]; then echo "darwin" ; else echo "linux" ; fi

bdelv avatar Feb 05 '20 19:02 bdelv

I think attempting to detect the OS if platform is empty is a good idea. A check like you suggested should work for Darwin and Linux and sounds like a good first step.

morgante avatar Feb 05 '20 19:02 morgante

any idea when this will be fixed?

smathalikunnel avatar Jun 02 '20 15:06 smathalikunnel

@bdelv Were you still planning to finish out #30?

morgante avatar Jun 02 '20 15:06 morgante

Sorry, I've left that on the side for too long. I got used to use Docker, then I got dragged away from Terraform. I can probably work on it by the end of the week if it's fine for you.

@smathalikunnel In the meantime, you can bypass the problem by using docker The way I'm bypassing it when i'm on MAC is to:

  • create a service account with enough rights
  • save it in JSON format
  • define a SERVICE_ACCOUNT_JSON env var like this export SERVICE_ACCOUNT_JSON=$(< ~/.credentials/name-of-sa.json)
  • copy the makefile defined in most terraform-google repos into your own repo then make docker_run you will have access to terraform in a linux env, so the right gcloud SDK will be used

Writing that, I realised that it will be better to fix the issue. :)

bdelv avatar Jun 02 '20 17:06 bdelv