Skip to content
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

change enable on adaptive_protection_config #12661

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6572.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed unable to manage Cloud Armor `adaptive_protection_config` on `google_compute_security_policy`
```
5 changes: 3 additions & 2 deletions google/resource_compute_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,9 @@ func expandLayer7DdosDefenseConfig(configured []interface{}) *compute.SecurityPo

data := configured[0].(map[string]interface{})
return &compute.SecurityPolicyAdaptiveProtectionConfigLayer7DdosDefenseConfig{
Enable: data["enable"].(bool),
RuleVisibility: data["rule_visibility"].(string),
Enable: data["enable"].(bool),
RuleVisibility: data["rule_visibility"].(string),
ForceSendFields: []string{"Enable"},
}
}

Expand Down
24 changes: 24 additions & 0 deletions google/resource_compute_security_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ func TestAccComputeSecurityPolicy_withAdaptiveProtection(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeSecurityPolicy_withAdaptiveProtectionUpdate(spName),
},
{
ResourceName: "google_compute_security_policy.policy",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -453,6 +461,22 @@ resource "google_compute_security_policy" "policy" {
`, spName)
}

func testAccComputeSecurityPolicy_withAdaptiveProtectionUpdate(spName string) string {
return fmt.Sprintf(`
resource "google_compute_security_policy" "policy" {
name = "%s"
description = "updated description"

adaptive_protection_config {
layer_7_ddos_defense_config {
enable = false
rule_visibility = "STANDARD"
}
}
}
`, spName)
}

func testAccComputeSecurityPolicy_withRateLimitOptions(spName string) string {
return fmt.Sprintf(`
resource "google_compute_security_policy" "policy" {
Expand Down