-
Notifications
You must be signed in to change notification settings - Fork 910
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
net-vpc-firewall when using yaml rule format fails to generate correct rule with source_tags #1058
Comments
Sorry about the appearance of the text. |
This is not supported. If you don't specify the range, we automatically use ["0.0.0.0/32"] as the default. Is this a use case you need? |
Although source ranges and source tags could be used together in combination. However, each could work independently without the other. If both are used together, the effective source set would be the union of both (see reference link below). For example, if I want to allow inbound traffic from specific servers with tag "mydb" only, I would build an inbound rule with source_tags="mydb" (without using any IP addresses); Need to find way to suppress auto generation of source_ranges=0.0.0.0/0. Alternatively, I could use the following generic TF module to generate rule with source_tags without source_ranges (attached below). However, I really prefer to keep every rules with the yaml file(s). It is a bad idea to scatter some rules with yaml format and other (exception) rules with various modules. resource "google_compute_firewall" "rules" {
project = var.project_id
name = "deny-connector-traffic-by-src-tag"
network = var.network
description = "deny inbound from VPC Connector by src tag"
direction = "INGRESS"
priority = 980
deny {
protocol = "ALL"
ports = []
}
source_tags = ["my-vpc-connector-tag"]
} |
Can you please format your comments properly using Markdown syntax? It makes it a lot easier for us to understand what you are saying. I changed yours to show you how it's done. |
We discussed it with Julio, and our consensus is that
I am closing this, feel free to reopen if you think our conclusions are not correct. |
Understood the point of the AND operation. In theory, both should produce same results but, surprisingly, It is either Google's documentation is wrong or there is a bug. Unfortunately, my plan of using the Yaml file to maintain firewall rules is no longer viable due to this bug. Unless I am willing to configure rules with source_tags by a separate module as outline earlier. Thank you very much your quick responses and enjoy the holidays. |
Wow I did not expect this. We'll try a few more tests before tossing in the towel. I reopened this issue to keep track. |
Hmmm, I just did a few tests and I'm not seeing the API interpolating 0/0. Guess we might indeed have to change our default. |
The behaviour using the resource is
My proposal is to do this in the module:
This mimicks the behaviour of the underlying resource. Would this work for your use case? |
Thanks ludoo, I believe your proposal would work. |
Thanks a lot for being persistent, and actually I was wrong: the API page is clear on the fact that ranges and tags are ORed. Thie fix is now merged, let me know if you run into more issues. |
It is working beautifully. |
Fantastic, thanks for confirming and have a nice holiday season! |
When configured GCP firewall rule with source_tags in Yaml format as the following, the net-vpc-firewall module always generate additional source_ranges = [0.0.0.0/0]. Same would also happened even I tried to set source_ranges = [].
Was that something I missed? How do I generate rule (in yaml) with source_tags but without source_ranges?
Thank you
============
Input yaml file with the following rule configuration:
source tag setting is not working;
always add sourceRanges 0.0.0.0/0 to the rule in addition to the specified sourceTags
Describe rule output:
Terraform apply output:
The text was updated successfully, but these errors were encountered: