Introduction
When using the Terraform CLI locally, you can use several methods to authenticate with Google Cloud. However, when you use HCP Terraform or Terraform Enterprise with the remote backend, you must configure the credentials as an environment variable in the target workspaces. This procedure outlines how to add a Google Cloud service account key as a sensitive environment variable.
Procedure
- Navigate to the Terraform Enterprise UI and select the appropriate organization.
- Select the workspace where you need to add the credentials.
- Select Variables from the workspace menu.
- In the Environment Variables section, click Add variable.
- Set the Key to
GOOGLE_CREDENTIALS. - Open your service account key file, copy the entire JSON content, and paste it into the Value field.
- Check the Sensitive box to protect the credential from being displayed in the UI or logs.
- Click Save variable.

- Queue a new plan in the workspace to verify that Terraform is using the new credentials to authenticate with Google Cloud.
Additional Information
- For more details on configuring the Google Provider, please see the Google Provider Reference: Credentials documentation.