Skip to content

Commit

Permalink
change enable on adaptive_protection_config (#6572) (#12661)
Browse files Browse the repository at this point in the history
* change enable on adaptive_protection_config

* Update resource_compute_security_policy_test.go.erb

lined a bracket

Co-authored-by: Edward Sun <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Signed-off-by: Modular Magician <[email protected]>
Co-authored-by: Edward Sun <[email protected]>
  • Loading branch information
modular-magician and Edward Sun authored Sep 27, 2022
1 parent 150211d commit 84dacaa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
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

0 comments on commit 84dacaa

Please sign in to comment.