diff --git a/.changelog/3010.txt b/.changelog/3010.txt new file mode 100644 index 0000000000..649162c4e8 --- /dev/null +++ b/.changelog/3010.txt @@ -0,0 +1,4 @@ +```release-note:bug +resource/cloudflare_teams_rules: fix block_page_enabled behaviour +``` + diff --git a/internal/sdkv2provider/resource_cloudflare_teams_rules.go b/internal/sdkv2provider/resource_cloudflare_teams_rules.go index 14f7136697..96838939e3 100644 --- a/internal/sdkv2provider/resource_cloudflare_teams_rules.go +++ b/internal/sdkv2provider/resource_cloudflare_teams_rules.go @@ -74,7 +74,7 @@ func resourceCloudflareTeamsRuleRead(ctx context.Context, d *schema.ResourceData return diag.FromErr(fmt.Errorf("error parsing rule version")) } - if err := d.Set("rule_settings", flattenTeamsRuleSettings(&rule.RuleSettings)); err != nil { + if err := d.Set("rule_settings", flattenTeamsRuleSettings(d, &rule.RuleSettings)); err != nil { return diag.FromErr(fmt.Errorf("error parsing rule settings")) } @@ -197,15 +197,15 @@ func resourceCloudflareTeamsRuleImport(ctx context.Context, d *schema.ResourceDa return []*schema.ResourceData{d}, nil } -func flattenTeamsRuleSettings(settings *cloudflare.TeamsRuleSettings) []interface{} { - if len(settings.OverrideIPs) == 0 && +func flattenTeamsRuleSettings(d *schema.ResourceData, settings *cloudflare.TeamsRuleSettings) []interface{} { + if _, ok := d.GetOkExists("block_page_enabled"); !ok && + len(settings.OverrideIPs) == 0 && settings.BlockReason == "" && settings.OverrideHost == "" && settings.BISOAdminControls == nil && settings.L4Override == nil && len(settings.AddHeaders) == 0 && settings.CheckSession == nil && - settings.BlockPageEnabled == false && settings.InsecureDisableDNSSECValidation == false && settings.EgressSettings == nil && settings.UntrustedCertSettings == nil && diff --git a/internal/sdkv2provider/resource_cloudflare_teams_rules_test.go b/internal/sdkv2provider/resource_cloudflare_teams_rules_test.go index 8217dc64e1..465376030b 100644 --- a/internal/sdkv2provider/resource_cloudflare_teams_rules_test.go +++ b/internal/sdkv2provider/resource_cloudflare_teams_rules_test.go @@ -42,7 +42,7 @@ func TestAccCloudflareTeamsRule_Basic(t *testing.T) { resource.TestCheckResourceAttr(name, "filters.0", "dns"), resource.TestCheckResourceAttr(name, "traffic", "any(dns.domains[*] == \"example.com\")"), resource.TestCheckResourceAttr(name, "rule_settings.#", "1"), - resource.TestCheckResourceAttr(name, "rule_settings.0.block_page_enabled", "false"), + resource.TestCheckResourceAttr(name, "rule_settings.0.block_page_enabled", "true"), resource.TestCheckResourceAttr(name, "rule_settings.0.block_page_reason", "cuz"), resource.TestCheckResourceAttr(name, "rule_settings.0.insecure_disable_dnssec_validation", "false"), resource.TestCheckResourceAttr(name, "rule_settings.0.egress.0.ipv4", "203.0.113.1"), @@ -66,7 +66,7 @@ resource "cloudflare_teams_rule" "%[1]s" { filters = ["dns"] traffic = "any(dns.domains[*] == \"example.com\")" rule_settings { - block_page_enabled = false + block_page_enabled = true block_page_reason = "cuz" insecure_disable_dnssec_validation = false egress {