@@ -162,6 +162,38 @@ func TestAccComputeSecurityPolicy_update(t *testing.T) {
162
162
})
163
163
}
164
164
165
+ func TestAccComputeSecurityPolicyRule_securityPolicyDefaultRule(t *testing.T) {
166
+ t.Parallel()
167
+
168
+ context := map[string]interface{}{
169
+ "random_suffix": acctest.RandString(t, 10),
170
+ }
171
+
172
+ acctest.VcrTest(t, resource.TestCase{
173
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
174
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
175
+ CheckDestroy: testAccCheckComputeSecurityPolicyRuleDestroyProducer(t),
176
+ Steps: []resource.TestStep{
177
+ {
178
+ Config: testAccComputeSecurityPolicyRule_securityPolicyDefaultRuleDeny(context),
179
+ },
180
+ {
181
+ ResourceName: "google_compute_security_policy_rule.policy_rule_default",
182
+ ImportState: true,
183
+ ImportStateVerify: true,
184
+ },
185
+ {
186
+ Config: testAccComputeSecurityPolicyRule_securityPolicyDefaultRuleAllow(context),
187
+ },
188
+ {
189
+ ResourceName: "google_compute_security_policy_rule.policy_rule_default",
190
+ ImportState: true,
191
+ ImportStateVerify: true,
192
+ },
193
+ },
194
+ })
195
+ }
196
+
165
197
func TestAccComputeSecurityPolicy_withAdvancedOptionsConfig(t *testing.T) {
166
198
t.Parallel()
167
199
@@ -879,6 +911,52 @@ resource "google_compute_security_policy" "policy" {
879
911
`, spName)
880
912
}
881
913
914
+ func testAccComputeSecurityPolicyRule_securityPolicyDefaultRuleDeny(context map[string]interface{}) string {
915
+ return acctest.Nprintf(`
916
+ resource "google_compute_security_policy" "default" {
917
+ name = "tf-test%{random_suffix}"
918
+ description = "basic global security policy"
919
+ type = "CLOUD_ARMOR"
920
+ }
921
+
922
+ resource "google_compute_security_policy_rule" "policy_rule_default" {
923
+ security_policy = google_compute_security_policy.default.name
924
+ description = "default rule"
925
+ action = "deny"
926
+ priority = "2147483647"
927
+ match {
928
+ versioned_expr = "SRC_IPS_V1"
929
+ config {
930
+ src_ip_ranges = ["*"]
931
+ }
932
+ }
933
+ }
934
+ `, context)
935
+ }
936
+
937
+ func testAccComputeSecurityPolicyRule_securityPolicyDefaultRuleAllow(context map[string]interface{}) string {
938
+ return acctest.Nprintf(`
939
+ resource "google_compute_security_policy" "default" {
940
+ name = "tf-test%{random_suffix}"
941
+ description = "basic global security policy"
942
+ type = "CLOUD_ARMOR"
943
+ }
944
+
945
+ resource "google_compute_security_policy_rule" "policy_rule_default" {
946
+ security_policy = google_compute_security_policy.default.name
947
+ description = "default rule"
948
+ action = "allow"
949
+ priority = "2147483647"
950
+ match {
951
+ versioned_expr = "SRC_IPS_V1"
952
+ config {
953
+ src_ip_ranges = ["*"]
954
+ }
955
+ }
956
+ }
957
+ `, context)
958
+ }
959
+
882
960
func testAccComputeSecurityPolicy_withRuleExpr(spName string) string {
883
961
return fmt.Sprintf(`
884
962
resource "google_compute_security_policy" "policy" {
0 commit comments