How to login:

don’t use a downloaded credential file https://jryancanty.medium.com/stop-downloading-google-cloud-service-account-keys-1811d44a97d9

instead

export GOOGLE_OAUTH_ACCESS_TOKEN="$(gcloud auth print-access-token)"

or

SERVICE_ACCOUNT="your-service-account-email"
export GOOGLE_OAUTH_ACCESS_TOKEN="$(gcloud --impersonate-service-account="${SERVICE_ACCOUNT}" auth print-access-token)"

followed by your terraform commands

or have a look at my automated setup https://github.com/TjenWellens/docker-alias

Also related to terraform: my terraform gcp setup template: https://github.com/TjenWellens/template-tf-gcp-init