TFE and GCP Service Account Credentials

Afternoon,

I am trying to get a workspace in TFE to auth to GCP with a service account.
VCS is Github.
The service account json file that GCP gives you is not available to TFE. T
he Google Provider doco says to use the json file and doesnt explain how NOT to use the json file.

How can I get the TFE workspace to auth against GCP if I cannot get the json file into TFE?

Hi @ausfestivus,

The GCP provider accepts either a path to a file containing JSON or a JSON string directly for credentials.

When using Terraform Cloud, you can configure the workspace with environment variables. For this particular case, you can add a GOOGLE_CREDENTIALS environment variable and paste your credentials JSON as its value. When Terraform Cloud runs Terraform it will set that environment variable, and the GCP provider will detect it and configure itself.

1 Like

Thanks Martin, the Hashicorp SE here came through with the same explanation.

I’ve put in a PR on the GCP provider doco to make this clearer to readers.

1 Like