@@ -733,3 +733,86 @@ resource "google_compute_subnetwork" "proxyonlysubnet2" {
733
733
734
734
` , cmName , netName , subnetName , pSubnetName , policyName , ruleName , gatewayName , gatewayScope , net2Name , subnet2Name , pSubnet2Name )
735
735
}
736
+
737
+ func TestAccNetworkServicesGateway_minimalSwp (t * testing.T ) {
738
+ netName := fmt .Sprintf ("tf-test-gateway-swp-net-%s" , acctest .RandString (t , 10 ))
739
+ subnetName := fmt .Sprintf ("tf-test-gateway-swp-subnet-%s" , acctest .RandString (t , 10 ))
740
+ pSubnetName := fmt .Sprintf ("tf-test-gateway-swp-proxyonly-%s" , acctest .RandString (t , 10 ))
741
+ policyName := fmt .Sprintf ("tf-test-gateway-swp-policy-%s" , acctest .RandString (t , 10 ))
742
+ ruleName := fmt .Sprintf ("tf-test-gateway-swp-rule-%s" , acctest .RandString (t , 10 ))
743
+ gatewayName := fmt .Sprintf ("tf-test-gateway-swp-%s" , acctest .RandString (t , 10 ))
744
+
745
+ acctest .VcrTest (t , resource.TestCase {
746
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
747
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
748
+ CheckDestroy : testAccCheckNetworkServicesGatewayDestroyProducer (t ),
749
+ Steps : []resource.TestStep {
750
+ {
751
+ Config : testAccNetworkServicesGateway_minimalSwp (netName , subnetName , pSubnetName , policyName , ruleName , gatewayName ),
752
+ },
753
+ {
754
+ ResourceName : "google_network_services_gateway.foobar" ,
755
+ ImportState : true ,
756
+ ImportStateVerify : true ,
757
+ ImportStateVerifyIgnore : []string {"name" , "location" , "delete_swg_autogen_router_on_destroy" },
758
+ },
759
+ },
760
+ })
761
+ }
762
+
763
+ func testAccNetworkServicesGateway_minimalSwp (netName , subnetName , pSubnetName , policyName , ruleName , gatewayName string ) string {
764
+ return fmt .Sprintf (`
765
+ resource "google_compute_network" "default" {
766
+ name = "%s"
767
+ routing_mode = "REGIONAL"
768
+ auto_create_subnetworks = false
769
+ }
770
+
771
+ resource "google_compute_subnetwork" "proxyonlysubnet" {
772
+ name = "%s"
773
+ purpose = "REGIONAL_MANAGED_PROXY"
774
+ ip_cidr_range = "192.168.0.0/23"
775
+ region = "us-central1"
776
+ network = google_compute_network.default.id
777
+ role = "ACTIVE"
778
+ }
779
+
780
+ resource "google_compute_subnetwork" "default" {
781
+ name = "%s"
782
+ purpose = "PRIVATE"
783
+ ip_cidr_range = "10.128.0.0/20"
784
+ region = "us-central1"
785
+ network = google_compute_network.default.id
786
+ role = "ACTIVE"
787
+ }
788
+
789
+ resource "google_network_security_gateway_security_policy" "default" {
790
+ name = "%s"
791
+ location = "us-central1"
792
+ }
793
+
794
+ resource "google_network_security_gateway_security_policy_rule" "default" {
795
+ name = "%s"
796
+ location = "us-central1"
797
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
798
+ enabled = true
799
+ priority = 1
800
+ session_matcher = "host() == 'example.com'"
801
+ basic_profile = "ALLOW"
802
+ }
803
+
804
+ resource "google_network_services_gateway" "foobar" {
805
+ name = "%s"
806
+ location = "us-central1"
807
+ addresses = ["10.128.0.99"]
808
+ type = "SECURE_WEB_GATEWAY"
809
+ ports = [443]
810
+ description = "my description"
811
+ gateway_security_policy = google_network_security_gateway_security_policy.default.id
812
+ network = google_compute_network.default.id
813
+ subnetwork = google_compute_subnetwork.default.id
814
+ delete_swg_autogen_router_on_destroy = true
815
+ depends_on = [google_compute_subnetwork.proxyonlysubnet]
816
+ }
817
+ ` , netName , subnetName , pSubnetName , policyName , ruleName , gatewayName )
818
+ }
0 commit comments