Reputation: 183
I am trying to configure a VPC peering between my project network and another project using GCP, however I can't because I don't have permissions to list networks on the other project.
resource "google_compute_network" "my-network" {
name = "foobar"
auto_create_subnetworks = "false"
}
resource "google_compute_network_peering" "my-network" {
name = "peering1"
network = "${google_compute_network.my-network.self_link}"
peer_network = "${data.google_compute_network.another-network.self_link}"
}
data "google_compute_network" "another-network" {
name = "another"
project = "another-project"
}
The error:
Error 403: Required 'compute.networks.get' permission for 'projects/another-project/global/networks/another', forbidden
Since terraform doesn't have access to another-project
I would like to know if there is any other way to do this with terraform.
Thank you in advance! :)
Upvotes: 2
Views: 3359
Reputation: 311
You have to use the selflink like that:
peer_network = "https://www.googleapis.com/compute/v1/projects/Peer_Project_ID/global/networks/Peer_network_name"
Change Peer_Project_ID and Peer_network_name with the right value
Upvotes: 0
Reputation: 106
If you know the name of the peer network just add the location:
peer_network = "projects/PEER_PROJECT/global/networks/PEER_NETWORK"
Upvotes: 9