I have an existing project on Google Cloud with say 10 instances. I am trying to authenticate in the existing project using credential file in the Terraform main.tf. I want to get all the instance IDs by mentioning the ProjectID and then add tags to all those existing instances.
You can’t use Terraform to piecemeal modify existing infrastructure attributes. You need to define
google_compute_instance resources for each of your instances and then
terraform import (https://www.terraform.io/docs/providers/google/r/compute_instance.html#import) to populate state.
At that point you can add the
tags attribute to your
terraform apply to modify them.