@@ -574,6 +574,8 @@ func TestAccIBMISVirtualEndpointGateway_DnsResolutionBindingMode(t *testing.T) {
574574 gatewayName3 := fmt .Sprintf ("tf-vpe-gateway-3-%d" , acctest .RandIntRange (10 , 100 ))
575575 gatewayName4 := fmt .Sprintf ("tf-vpe-gateway-4-%d" , acctest .RandIntRange (10 , 100 ))
576576 gatewayName5 := fmt .Sprintf ("tf-vpe-gateway-5-%d" , acctest .RandIntRange (10 , 100 ))
577+ gatewayName6 := fmt .Sprintf ("tf-vpe-gateway-6-%d" , acctest .RandIntRange (10 , 100 ))
578+ gatewayName7 := fmt .Sprintf ("tf-vpe-gateway-7-%d" , acctest .RandIntRange (10 , 100 ))
577579
578580 resource .Test (t , resource.TestCase {
579581 PreCheck : func () { acc .TestAccPreCheck (t ) },
@@ -593,83 +595,205 @@ func TestAccIBMISVirtualEndpointGateway_DnsResolutionBindingMode(t *testing.T) {
593595 testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , & endpointGateway ),
594596 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "name" , gatewayName1 ),
595597 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "allow_dns_resolution_binding" , "true" ),
596- // Verify new field gets computed correctly (true maps to "primary")
597598 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "dns_resolution_binding_mode" , "primary" ),
598599 ),
599600 },
600- // Step 3: Remove VPE Gateway 1 - VPC only
601+ // Step 3: Update VPE Gateway 1 - Change deprecated field from true to false (in-place update)
602+ {
603+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName1 , "vpe_gateway_1" , "deprecated" , "false" , "" ),
604+ Check : resource .ComposeTestCheckFunc (
605+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , & endpointGateway ),
606+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "name" , gatewayName1 ),
607+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "allow_dns_resolution_binding" , "false" ),
608+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_1" , "dns_resolution_binding_mode" , "disabled" ),
609+ ),
610+ },
611+ // Step 4: Remove VPE Gateway 1 - VPC only
601612 {
602613 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
603614 Check : resource .ComposeTestCheckFunc (
604615 resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
605616 ),
606617 },
607- // Step 4 : Add VPE Gateway 2 - Deprecated field with allow_dns_resolution_binding = false
618+ // Step 5 : Add VPE Gateway 2 - Deprecated field with allow_dns_resolution_binding = false
608619 {
609620 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName2 , "vpe_gateway_2" , "deprecated" , "false" , "" ),
610621 Check : resource .ComposeTestCheckFunc (
611622 testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_2" , & endpointGateway ),
612623 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_2" , "name" , gatewayName2 ),
613624 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_2" , "allow_dns_resolution_binding" , "false" ),
614- // Verify new field gets computed correctly (false maps to "disabled")
615625 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_2" , "dns_resolution_binding_mode" , "disabled" ),
616626 ),
617627 },
618- // Step 5 : Remove VPE Gateway 2 - VPC only
628+ // Step 6 : Remove VPE Gateway 2 - VPC only
619629 {
620630 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
621631 Check : resource .ComposeTestCheckFunc (
622632 resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
623633 ),
624634 },
625- // Step 6 : Add VPE Gateway 3 - New field with dns_resolution_binding_mode = "primary"
635+ // Step 7 : Add VPE Gateway 3 - New field with dns_resolution_binding_mode = "primary"
626636 {
627637 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName3 , "vpe_gateway_3" , "new" , "" , "primary" ),
628638 Check : resource .ComposeTestCheckFunc (
629639 testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , & endpointGateway ),
630640 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "name" , gatewayName3 ),
631641 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "dns_resolution_binding_mode" , "primary" ),
632- // Verify deprecated field shows correct computed value
633642 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "allow_dns_resolution_binding" , "true" ),
634643 ),
635644 },
636- // Step 7: Remove VPE Gateway 3 - VPC only
645+ // Step 8: Update VPE Gateway 3 - Change new field from primary to disabled (in-place update)
646+ {
647+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName3 , "vpe_gateway_3" , "new" , "" , "disabled" ),
648+ Check : resource .ComposeTestCheckFunc (
649+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , & endpointGateway ),
650+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "name" , gatewayName3 ),
651+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "dns_resolution_binding_mode" , "disabled" ),
652+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_3" , "allow_dns_resolution_binding" , "false" ),
653+ ),
654+ },
655+ // Step 9: Update VPE Gateway 3 - Change to per_resource_binding (in-place update)
656+ // {
657+ // Config: testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig(vpcName, gatewayName3, "vpe_gateway_3", "new", "", "per_resource_binding"),
658+ // Check: resource.ComposeTestCheckFunc(
659+ // testAccCheckisVirtualEndpointGatewayExists("ibm_is_virtual_endpoint_gateway.vpe_gateway_3", &endpointGateway),
660+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_3", "name", gatewayName3),
661+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_3", "dns_resolution_binding_mode", "per_resource_binding"),
662+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_3", "allow_dns_resolution_binding", "true"),
663+ // ),
664+ // },
665+ // Step 10: Remove VPE Gateway 3 - VPC only
637666 {
638667 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
639668 Check : resource .ComposeTestCheckFunc (
640669 resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
641670 ),
642671 },
643- // Step 8: Add VPE Gateway 4 - New field with dns_resolution_binding_mode = "disabled"
672+ // Step 11: Add VPE Gateway 4 - Deprecated field with allow_dns_resolution_binding = true
673+ {
674+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName4 , "vpe_gateway_4" , "deprecated" , "true" , "" ),
675+ Check : resource .ComposeTestCheckFunc (
676+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , & endpointGateway ),
677+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "name" , gatewayName4 ),
678+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "allow_dns_resolution_binding" , "true" ),
679+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "dns_resolution_binding_mode" , "primary" ),
680+ ),
681+ },
682+ // Step 12: MIGRATION - Remove deprecated field, add new field with equivalent value (primary)
644683 {
645- Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName4 , "vpe_gateway_4" , "new" , "" , "disabled " ),
684+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName4 , "vpe_gateway_4" , "new" , "" , "primary " ),
646685 Check : resource .ComposeTestCheckFunc (
647686 testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , & endpointGateway ),
648687 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "name" , gatewayName4 ),
649- resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "dns_resolution_binding_mode" , "disabled" ),
650- // Verify deprecated field shows correct computed value
651- resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "allow_dns_resolution_binding" , "false" ),
688+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "dns_resolution_binding_mode" , "primary" ),
689+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_4" , "allow_dns_resolution_binding" , "true" ),
652690 ),
653691 },
654- // Step 9: Remove VPE Gateway 4 - VPC only
692+ // Step 13: Update to per_resource_binding (new capability not available in deprecated field)
693+ // {
694+ // Config: testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig(vpcName, gatewayName4, "vpe_gateway_4", "new", "", "per_resource_binding"),
695+ // Check: resource.ComposeTestCheckFunc(
696+ // testAccCheckisVirtualEndpointGatewayExists("ibm_is_virtual_endpoint_gateway.vpe_gateway_4", &endpointGateway),
697+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_4", "name", gatewayName4),
698+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_4", "dns_resolution_binding_mode", "per_resource_binding"),
699+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_4", "allow_dns_resolution_binding", "true"),
700+ // ),
701+ // },
702+ // Step 14: Remove VPE Gateway 4 - VPC only
655703 {
656704 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
657705 Check : resource .ComposeTestCheckFunc (
658706 resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
659707 ),
660708 },
661- // Step 10 : Add VPE Gateway 5 - New field with dns_resolution_binding_mode = "per_resource_binding"
709+ // Step 15 : Add VPE Gateway 5 - Deprecated field with allow_dns_resolution_binding = false
662710 {
663- Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName5 , "vpe_gateway_5" , "new " , "" , "per_resource_binding " ),
711+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName5 , "vpe_gateway_5" , "deprecated " , "false " , "" ),
664712 Check : resource .ComposeTestCheckFunc (
665713 testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , & endpointGateway ),
666714 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "name" , gatewayName5 ),
667- resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "dns_resolution_binding_mode" , "per_resource_binding" ),
668- // Verify deprecated field shows correct computed value
715+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "allow_dns_resolution_binding" , "false" ),
716+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "dns_resolution_binding_mode" , "disabled" ),
717+ ),
718+ },
719+ // Step 16: MIGRATION - Remove deprecated field (false), add new field with equivalent value (disabled)
720+ {
721+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName5 , "vpe_gateway_5" , "new" , "" , "disabled" ),
722+ Check : resource .ComposeTestCheckFunc (
723+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , & endpointGateway ),
724+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "name" , gatewayName5 ),
725+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "dns_resolution_binding_mode" , "disabled" ),
726+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "allow_dns_resolution_binding" , "false" ),
727+ ),
728+ },
729+ // Step 17: Update to primary (enabling DNS resolution binding)
730+ {
731+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName5 , "vpe_gateway_5" , "new" , "" , "primary" ),
732+ Check : resource .ComposeTestCheckFunc (
733+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , & endpointGateway ),
734+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "name" , gatewayName5 ),
735+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "dns_resolution_binding_mode" , "primary" ),
669736 resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_5" , "allow_dns_resolution_binding" , "true" ),
670737 ),
671738 },
672- // Step 11: Final cleanup - Remove VPE Gateway 5, VPC remains (will be cleaned up by test framework)
739+ // Step 18: Remove VPE Gateway 5 - VPC only
740+ {
741+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
742+ Check : resource .ComposeTestCheckFunc (
743+ resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
744+ ),
745+ },
746+ // Step 19: Add VPE Gateway 6 - No field specified (test default behavior)
747+ {
748+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName6 , "vpe_gateway_6" , "none" , "" , "" ),
749+ Check : resource .ComposeTestCheckFunc (
750+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_6" , & endpointGateway ),
751+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_6" , "name" , gatewayName6 ),
752+ // Should have computed default values from API
753+ resource .TestCheckResourceAttrSet ("ibm_is_virtual_endpoint_gateway.vpe_gateway_6" , "dns_resolution_binding_mode" ),
754+ resource .TestCheckResourceAttrSet ("ibm_is_virtual_endpoint_gateway.vpe_gateway_6" , "allow_dns_resolution_binding" ),
755+ ),
756+ },
757+ // Step 20: Remove VPE Gateway 6 - VPC only
758+ {
759+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
760+ Check : resource .ComposeTestCheckFunc (
761+ resource .TestCheckResourceAttr ("ibm_is_vpc.testacc_vpc" , "name" , vpcName ),
762+ ),
763+ },
764+ // Step 21: Add VPE Gateway 7 - Test all three modes sequentially via updates
765+ {
766+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName7 , "vpe_gateway_7" , "new" , "" , "disabled" ),
767+ Check : resource .ComposeTestCheckFunc (
768+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , & endpointGateway ),
769+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , "dns_resolution_binding_mode" , "disabled" ),
770+ ),
771+ },
772+ // Step 22: Update VPE Gateway 7 to primary
773+ {
774+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName7 , "vpe_gateway_7" , "new" , "" , "primary" ),
775+ Check : resource .ComposeTestCheckFunc (
776+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , & endpointGateway ),
777+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , "dns_resolution_binding_mode" , "primary" ),
778+ ),
779+ },
780+ // Step 23: Update VPE Gateway 7 to per_resource_binding
781+ // {
782+ // Config: testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig(vpcName, gatewayName7, "vpe_gateway_7", "new", "", "per_resource_binding"),
783+ // Check: resource.ComposeTestCheckFunc(
784+ // testAccCheckisVirtualEndpointGatewayExists("ibm_is_virtual_endpoint_gateway.vpe_gateway_7", &endpointGateway),
785+ // resource.TestCheckResourceAttr("ibm_is_virtual_endpoint_gateway.vpe_gateway_7", "dns_resolution_binding_mode", "per_resource_binding"),
786+ // ),
787+ // },
788+ // Step 24: Update VPE Gateway 7 back to disabled (full cycle)
789+ {
790+ Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig (vpcName , gatewayName7 , "vpe_gateway_7" , "new" , "" , "disabled" ),
791+ Check : resource .ComposeTestCheckFunc (
792+ testAccCheckisVirtualEndpointGatewayExists ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , & endpointGateway ),
793+ resource .TestCheckResourceAttr ("ibm_is_virtual_endpoint_gateway.vpe_gateway_7" , "dns_resolution_binding_mode" , "disabled" ),
794+ ),
795+ },
796+ // Step 25: Final cleanup - Remove VPE Gateway 7, VPC remains
673797 {
674798 Config : testAccCheckIBMISVirtualEndpointGatewayComprehensiveVPCOnly (vpcName ),
675799 Check : resource .ComposeTestCheckFunc (
@@ -713,7 +837,7 @@ func testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig(vpcName, gateway
713837
714838 allow_dns_resolution_binding = %s
715839 }` , resourceName , gatewayName , deprecatedValue )
716- } else {
840+ } else if fieldType == "new" {
717841 // Using new field
718842 gatewayConfig = fmt .Sprintf (`
719843 resource "ibm_is_virtual_endpoint_gateway" "%s" {
@@ -727,6 +851,18 @@ func testAccCheckIBMISVirtualEndpointGatewayComprehensiveConfig(vpcName, gateway
727851
728852 dns_resolution_binding_mode = "%s"
729853 }` , resourceName , gatewayName , newValue )
854+ } else if fieldType == "none" {
855+ // No DNS field specified - test defaults
856+ gatewayConfig = fmt .Sprintf (`
857+ resource "ibm_is_virtual_endpoint_gateway" "%s" {
858+ name = "%s"
859+ vpc = ibm_is_vpc.testacc_vpc.id
860+
861+ target {
862+ name = "ibm-ntp-server"
863+ resource_type = "provider_infrastructure_service"
864+ }
865+ }` , resourceName , gatewayName )
730866 }
731867
732868 return baseConfig + gatewayConfig
0 commit comments