Google Cloud credentials with Terraform
if I configure Terraform to point to the application_default_credentials.json file, I get the following errors:
The credentials
field in provider config expects a path to service account key file, not user account credentials file. If you want to authenticate with your user account try omitting credentials
and then running gcloud auth application-default login
; if Terraform doesn't find your credentials file you can set the .GOOGLE_APPLICATION_CREDENTIALS
environment variabe to point to ~/.config/gcloud/application_default_credentials.json
Read here for more on the topic of service accounts vs user accounts. For what it's worth, Terraform docs explicitly advice against using application-default login
:
This approach isn't recommended- some APIs are not compatible with credentials obtained through gcloud
Similarly GCP docs state the following:
Important: For almost all cases, whether you are developing locally or in a production application, you should use service accounts, rather than user accounts or API keys.