You are trying to connect the GCP cloud from Terraform. Terraform will use the GCP SDK to connect to your project. But the first time you have to manually login to your GCP cloud from the command line using the below-given command.
$ gcloud auth application-default login
Hope this helped!!
To know more about Google Cloud, It is recommended to go for Google Cloud Certification training today.