@@ -189,6 +189,43 @@ func TestAccComputeFirewallPolicyRule_basic(t *testing.T) {
189189 })
190190}
191191
192+ func TestAccComputeFirewallPolicyRule_disabled_enabled (t * testing.T ) {
193+ t .Parallel ()
194+
195+ context := map [string ]interface {}{
196+ "random_suffix" : acctest .RandString (t , 10 ),
197+ "org_name" : fmt .Sprintf ("organizations/%s" , envvar .GetTestOrgFromEnv (t )),
198+ }
199+
200+ acctest .VcrTest (t , resource.TestCase {
201+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
202+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
203+ Steps : []resource.TestStep {
204+ {
205+ Config : testAccComputeFirewallPolicyRule_disabled (context , true ),
206+ },
207+ {
208+ ResourceName : "google_compute_firewall_policy_rule.default" ,
209+ ImportState : true ,
210+ ImportStateVerify : true ,
211+ ImportStateVerifyIgnore : []string {"firewall_policy" },
212+ },
213+ {
214+ Config : testAccComputeFirewallPolicyRule_disabled (context , false ),
215+ Check : resource .ComposeTestCheckFunc (
216+ resource .TestCheckResourceAttr ("google_compute_firewall_policy_rule.default" , "disabled" , "false" ),
217+ ),
218+ },
219+ {
220+ ResourceName : "google_compute_firewall_policy_rule.default" ,
221+ ImportState : true ,
222+ ImportStateVerify : true ,
223+ ImportStateVerifyIgnore : []string {"firewall_policy" },
224+ },
225+ },
226+ })
227+ }
228+
192229func testAccComputeFirewallPolicyRule_basic (context map [string ]interface {}) string {
193230 return acctest .Nprintf (`
194231resource "google_folder" "folder" {
@@ -794,3 +831,39 @@ resource "google_compute_firewall_policy_rule" "fw_policy_rule3" {
794831}
795832` , context )
796833}
834+
835+ func testAccComputeFirewallPolicyRule_disabled (context map [string ]interface {}, disabled bool ) string {
836+ context ["disabled" ] = fmt .Sprintf ("%t" , disabled )
837+ return acctest .Nprintf (`
838+ resource "google_folder" "default" {
839+ display_name = "tf-test-folder-%{random_suffix}"
840+ parent = "%{org_name}"
841+ deletion_protection = false
842+ }
843+
844+ resource "google_compute_firewall_policy" "default" {
845+ parent = google_folder.default.name
846+ short_name = "tf-test-policy-%{random_suffix}"
847+ description = "Resource created for Terraform acceptance testing"
848+ }
849+
850+ resource "google_compute_firewall_policy_rule" "default" {
851+ firewall_policy = google_compute_firewall_policy.default.name
852+ description = "Resource created for Terraform acceptance testing"
853+ priority = 9000
854+ enable_logging = true
855+ action = "allow"
856+ direction = "EGRESS"
857+ disabled = %{disabled}
858+
859+ match {
860+ dest_ip_ranges = ["35.235.240.0/20"]
861+
862+ layer4_configs {
863+ ip_protocol = "tcp"
864+ ports = [22]
865+ }
866+ }
867+ }
868+ ` , context )
869+ }
0 commit comments