Hello, I hope you are all OK
I have some issue with terraform and GCP.
The goal is to create a Cloud Composer instance on project A and to retrieve the network resources (network & subnetwork) from project B.
I used a data-sources.tf file, but it doesn’t seem to be working. My data-sources.tf file specifies the network resources from project B, but in my composer.tf file, I indicate that it should create the Cloud Composer instance in project A.
Are you using a single GCP provider block? Such as:
provider "google" {
project = "{{YOUR GCP PROJECT}}"
region = "us-central1"
zone = "us-central1-c"
}
If this is the case then that provider will only access the resources in the project referenced as documented the google provider block references a single project.
I would suggest you set up a second provider with an alias for use with the data sources from the other project. Leaving the default provider (without alias) to be the one referencing the project where you are deploying. And then update the data resources that are getting information from the other project:
data "aws_some_resource" "some_name" {
provider = aws.alias_name
# ...
}