-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google_compute_forwarding_rule does not support shared VPC #858
Comments
Hi, Have you tried using the subnetwork data source? data "google_compute_subnetwork" "my-subnetwork" {
name = "${var.subnetwork}"
project = "your vpc host project"
region = "us-east1"
}
resource "google_compute_forwarding_rule" "forwarding-rule" {
name = "${var.name}-fw-rule"
load_balancing_scheme = "INTERNAL"
ports = ["${var.port}"]
subnetwork = "${data.google_compute_subnetwork.my-subnetwork.self_link}"
backend_service = "${google_compute_region_backend_service.backend.self_link}"
} |
@rosbo |
I agree, we should be consistent across resources. I will leave it open to fix this. |
Hi @rosbo , I have the same problem, and I also define the data source in module, but I get the error below:
|
@jason-tian, this should work. Could you share your config and we can start from there to determine what is missing? Thank you |
I don't see the data source for the subnetwork in your config. You should have a block like: data "google_compute_subnetwork" "my-subnetwork" {
name = "${var.subnetwork}"
project = "your vpc host project"
region = "us-east1"
} |
Sorry, I miss it. let me show it again. the module app:
The tf file which is use the module:
|
@rosbo Sorry to paste wrong config before. Above should be that I am using. |
Can you try passing the project and the region to the datasource. If you do not, it falls back on the default defined in your provider block. data "google_compute_subnetwork" "my-subnetwork" {
name = "${var.subnetwork}"
project = "${var.subnetwork_project}"
region = "${var.region}"
} |
It works. I misunderstood before about the project and region. Thanks for your help. @rosbo |
You're welcome. Glad that it works now! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
I think there are two issues which as a result does not allow using
google_compute_forwarding_rule
with shared VPCs.subnetwork
field expects an URL not just a name - in other compute resources like instance and template this filed is just network namesubnetwork_project
field which might help with issue above.Terraform Version
Terraform v0.11.1
provider "google" (1.4.0)
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
One should be able to use Shared VPC subnetwork for creating forwarding rule. It can be done via WebUI
Actual Behavior
When
subnetwork
field is just subnetwork name terraform fails with:* google_compute_forwarding_rule.forwarding-rule: Error creating ForwardingRule: googleapi: Error 400: Invalid value for field 'resource.subnetwork': 'my-xpn-subnetwork-name'. The URL is malformed., invalid
Steps to Reproduce
Important Factoids
Shared network should be created and be in different project.
References
The text was updated successfully, but these errors were encountered: