-
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_security_policy rules are always recreated if they have a match expr set #9084
google_compute_security_policy rules are always recreated if they have a match expr set #9084
Comments
I vaguely remember this - the summary of my findings is in GoogleCloudPlatform/magic-modules#4472. TLDR there is an outstanding issue here. Since I've lost the context it would probably make sense to assign this to the current bug onduty. What's happening: - - rule {
- - action = "allow" -> null
- - description = "description" -> null
- - preview = false -> null
- - priority = 100 -> null
- - match {
- - expr {
- - expression = "request.path.matches('/some/path/')" -> null
}
}
}
+ + rule {
+ + action = "allow"
+ + description = "description"
+ + preview = false
+ + priority = 100
+ + match {
+ + expr {
+ + expression = "request.path.matches('/some/path/')"
}
}
}
How to reproduce: Should be possible to reproduce by setting up a rule that has a match using expr, then adding a new rule (without changing the one that uses match expr). This will erroneously trigger a recreate of the existing rule. |
I have a similar issue. Terraform always wants to recreate all rules in the security policy when the list of IP ranges differs from what's in the state. This has been going on since Terraform 0.12 AFAIK. |
b/196186416 |
Is there any update on this issue? |
Likely need to switch the field to an un-ordered list (similar to BT table, compute disk?). Marking as persistent-bug to discuss in triage |
Hi, any updates? |
Our company is facing this bug and I'm working on it. According to my research, the unspecified So, setting the default value of This change looks like a major change because it is a change of the default value, but the default value of In our company, there is a module containing |
@wata727 I'm not seeing your change fix the extra diffs, have you been able to test it out locally and see the fix? I am able to get the diff to not show up when I specify the |
@slevenick Yes. I confirmed the fix suppressed extra diffs in my case. The following are repro steps:
terraform {
required_providers {
google = {
version = "4.14.0"
}
}
}
resource "google_compute_security_policy" "policy" {
name = "my-policy"
rule {
action = "deny(403)"
priority = "1000"
match {
expr {
expression = "request.path.matches('/admin')"
}
}
description = "only admin"
}
rule {
action = "allow"
priority = "2147483647"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
description = "default rule"
}
}
diff --git a/workdir/main.tf b/workdir/main.tf
index 5b49c5c04..89b6403cc 100644
--- a/workdir/main.tf
+++ b/workdir/main.tf
@@ -29,6 +29,6 @@ resource "google_compute_security_policy" "policy" {
src_ip_ranges = ["*"]
}
}
- description = "default rule"
+ description = "default rule (allow all requests)"
}
}
diff --git a/google/resource_compute_security_policy.go b/google/resource_compute_security_policy.go
index 1fd09c3f0..d55f274a5 100644
--- a/google/resource_compute_security_policy.go
+++ b/google/resource_compute_security_policy.go
@@ -99,6 +99,7 @@ func resourceComputeSecurityPolicy() *schema.Resource {
"versioned_expr": {
Type: schema.TypeString,
Optional: true,
+ Default: "",
ValidateFunc: validation.StringInSlice([]string{"SRC_IPS_V1"}, false),
Description: `Predefined rule expression. If this field is specified, config must also be specified. Available options: SRC_IPS_V1: Must specify the corresponding src_ip_ranges field in config.`,
},
Environment:
As in the repro above, I think this solution is not correct because it happens even if the |
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. |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
0.15.1
Affected Resource(s)
References
I believe #8437 should be re-opened. It was originally created because #8251 was closed, and @melinath asked @Sreerag74031 to open a new one to continue discussion of the larger issue that was found. But then #8437 was closed because #8251 already existed (but was already closed).
The issue still seems to affect me on the latest version, and the above issues don't suggest that a solution was ever implemented.
Internal issue: http://b/196186416
The text was updated successfully, but these errors were encountered: