@@ -1256,6 +1256,67 @@ func testAccCheckIBMISVPCCustomResolverDelegatedToSystemConfig(vpcname1, vpcname
12561256 }
12571257 ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 )
12581258}
1259+ func testAccCheckIBMISVPCCustomResolverDelegatedToSystemVPCCrnConfig (vpcname1 , vpcname2 string ) string {
1260+ return fmt .Sprintf (`
1261+ resource "ibm_is_vpc" "hub_true" {
1262+ name = "%s"
1263+ dns {
1264+ enable_hub = true
1265+ }
1266+ }
1267+ resource "ibm_is_subnet" "hub_true_sub1" {
1268+ name = "hub-true-subnet1"
1269+ vpc = ibm_is_vpc.hub_true.id
1270+ zone = "%s"
1271+ total_ipv4_address_count = 16
1272+ }
1273+ resource "ibm_is_subnet" "hub_true_sub2" {
1274+ name = "hub-true-subnet2"
1275+ vpc = ibm_is_vpc.hub_true.id
1276+ zone = "%s"
1277+ total_ipv4_address_count = 16
1278+ }
1279+ resource "ibm_resource_instance" "dns-cr-instance" {
1280+ name = "dns-cr-instance"
1281+ resource_group_id = data.ibm_resource_group.rg.id
1282+ location = "global"
1283+ service = "dns-svcs"
1284+ plan = "standard-dns"
1285+ }
1286+ resource "ibm_dns_custom_resolver" "test_hub_true" {
1287+ name = "test-hub-true-customresolver"
1288+ instance_id = ibm_resource_instance.dns-cr-instance.guid
1289+ description = "new test CR - TF"
1290+ high_availability = true
1291+ enabled = true
1292+ locations {
1293+ subnet_crn = ibm_is_subnet.hub_true_sub1.crn
1294+ enabled = true
1295+ }
1296+ locations {
1297+ subnet_crn = ibm_is_subnet.hub_true_sub2.crn
1298+ enabled = true
1299+ }
1300+ }
1301+ // delegated vpc
1302+ resource "ibm_is_vpc" "hub_false_delegated" {
1303+ depends_on = [ibm_dns_custom_resolver.test_hub_true]
1304+ name = "%s"
1305+ dns {
1306+ enable_hub = false
1307+ resolver {
1308+ type = "system"
1309+ dns_binding_name = "null"
1310+ vpc_crn = "null"
1311+ }
1312+ }
1313+ }
1314+
1315+ data "ibm_resource_group" "rg" {
1316+ is_default = true
1317+ }
1318+ ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 )
1319+ }
12591320
12601321// VPC DNS name update fix
12611322// TestAccIBMISVPC_ResolverTypeTransitionDnsNameUpdate tests the transition of resolver types in a VPC.
@@ -1343,6 +1404,90 @@ func TestAccIBMISVPC_ResolverTypeTransitionDnsNameUpdate(t *testing.T) {
13431404 },
13441405 })
13451406}
1407+ func TestAccIBMISVPC_ResolverTypeTransitionDnsNameVPCCrnUpdate (t * testing.T ) {
1408+ var vpc string
1409+ vpcname1 := fmt .Sprintf ("tf-vpc-hub-true-%d" , acctest .RandIntRange (10 , 100 ))
1410+ vpcname2 := fmt .Sprintf ("tf-vpc-hub-false-%d" , acctest .RandIntRange (10 , 100 ))
1411+ dnsName := fmt .Sprintf ("tf-dns-%d" , acctest .RandIntRange (10 , 100 ))
1412+ dnsNameUpdated := fmt .Sprintf ("tf-dns-update-%d" , acctest .RandIntRange (10 , 100 ))
1413+
1414+ resource .Test (t , resource.TestCase {
1415+ PreCheck : func () { acc .TestAccPreCheck (t ) },
1416+ Providers : acc .TestAccProviders ,
1417+ CheckDestroy : testAccCheckIBMISVPCDestroy ,
1418+ Steps : []resource.TestStep {
1419+ // Step 1: Initial setup with system resolver
1420+ {
1421+ Config : testAccCheckIBMISVPCResolverSystemConfig (vpcname1 , vpcname2 ),
1422+ Check : resource .ComposeTestCheckFunc (
1423+ testAccCheckIBMISVPCExists ("ibm_is_vpc.hub_false_delegated" , vpc ),
1424+ resource .TestCheckResourceAttr (
1425+ "ibm_is_vpc.hub_false_delegated" , "name" , vpcname2 ),
1426+ resource .TestCheckResourceAttr (
1427+ "ibm_is_vpc.hub_false_delegated" , "dns.0.enable_hub" , "false" ),
1428+ resource .TestCheckResourceAttr (
1429+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.type" , "system" ),
1430+ resource .TestCheckResourceAttr (
1431+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.vpc_crn" , "" ),
1432+ resource .TestCheckResourceAttr (
1433+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.dns_binding_name" , "" ),
1434+ ),
1435+ },
1436+ // Step 2: Change to delegated resolver with no name
1437+ {
1438+ Config : testAccCheckIBMISVPCCustomResolverDelegatedWithNoNameVpcCrnConfig (vpcname1 , vpcname2 ),
1439+ Check : resource .ComposeTestCheckFunc (
1440+ testAccCheckIBMISVPCExists ("ibm_is_vpc.hub_false_delegated" , vpc ),
1441+ resource .TestCheckResourceAttr (
1442+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.type" , "delegated" ),
1443+ resource .TestCheckResourceAttrSet (
1444+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.vpc_crn" ),
1445+ resource .TestCheckResourceAttrSet (
1446+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.dns_binding_name" ),
1447+ ),
1448+ },
1449+ // Step 3: Update the binding name
1450+ {
1451+ Config : testAccCheckIBMISVPCCustomResolverDelegatedWithNameVPCCrnConfig (vpcname1 , vpcname2 , dnsName ),
1452+ Check : resource .ComposeTestCheckFunc (
1453+ testAccCheckIBMISVPCExists ("ibm_is_vpc.hub_false_delegated" , vpc ),
1454+ resource .TestCheckResourceAttr (
1455+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.type" , "delegated" ),
1456+ resource .TestCheckResourceAttrSet (
1457+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.vpc_crn" ),
1458+ resource .TestCheckResourceAttr (
1459+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.dns_binding_name" , dnsName ),
1460+ ),
1461+ },
1462+ // Step 4: Update the binding name again
1463+ {
1464+ Config : testAccCheckIBMISVPCCustomResolverDelegatedWithNameVPCCrnConfig (vpcname1 , vpcname2 , dnsNameUpdated ),
1465+ Check : resource .ComposeTestCheckFunc (
1466+ testAccCheckIBMISVPCExists ("ibm_is_vpc.hub_false_delegated" , vpc ),
1467+ resource .TestCheckResourceAttr (
1468+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.type" , "delegated" ),
1469+ resource .TestCheckResourceAttrSet (
1470+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.vpc_crn" ),
1471+ resource .TestCheckResourceAttr (
1472+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.dns_binding_name" , dnsNameUpdated ),
1473+ ),
1474+ },
1475+ // Step 5: Change back to system resolver
1476+ {
1477+ Config : testAccCheckIBMISVPCCustomResolverDelegatedToSystemVPCCrnConfig (vpcname1 , vpcname2 ),
1478+ Check : resource .ComposeTestCheckFunc (
1479+ testAccCheckIBMISVPCExists ("ibm_is_vpc.hub_false_delegated" , vpc ),
1480+ resource .TestCheckResourceAttr (
1481+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.type" , "system" ),
1482+ resource .TestCheckResourceAttr (
1483+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.vpc_crn" , "" ),
1484+ resource .TestCheckResourceAttr (
1485+ "ibm_is_vpc.hub_false_delegated" , "dns.0.resolver.0.dns_binding_name" , "" ),
1486+ ),
1487+ },
1488+ },
1489+ })
1490+ }
13461491
13471492// Helper function to generate config for custom resolver with hub VPC
13481493func testAccCheckIBMISVPCCustomResolverDelegatedWithNoNameConfig (vpcname1 , vpcname2 string ) string {
@@ -1405,6 +1550,66 @@ func testAccCheckIBMISVPCCustomResolverDelegatedWithNoNameConfig(vpcname1, vpcna
14051550 }
14061551 ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 )
14071552}
1553+ func testAccCheckIBMISVPCCustomResolverDelegatedWithNoNameVpcCrnConfig (vpcname1 , vpcname2 string ) string {
1554+ return fmt .Sprintf (`
1555+ resource "ibm_is_vpc" "hub_true" {
1556+ name = "%s"
1557+ dns {
1558+ enable_hub = true
1559+ }
1560+ }
1561+ resource "ibm_is_subnet" "hub_true_sub1" {
1562+ name = "hub-true-subnet1"
1563+ vpc = ibm_is_vpc.hub_true.id
1564+ zone = "%s"
1565+ total_ipv4_address_count = 16
1566+ }
1567+ resource "ibm_is_subnet" "hub_true_sub2" {
1568+ name = "hub-true-subnet2"
1569+ vpc = ibm_is_vpc.hub_true.id
1570+ zone = "%s"
1571+ total_ipv4_address_count = 16
1572+ }
1573+ resource "ibm_resource_instance" "dns-cr-instance" {
1574+ name = "dns-cr-instance"
1575+ resource_group_id = data.ibm_resource_group.rg.id
1576+ location = "global"
1577+ service = "dns-svcs"
1578+ plan = "standard-dns"
1579+ }
1580+ resource "ibm_dns_custom_resolver" "test_hub_true" {
1581+ name = "test-hub-true-customresolver"
1582+ instance_id = ibm_resource_instance.dns-cr-instance.guid
1583+ description = "new test CR - TF"
1584+ high_availability = true
1585+ enabled = true
1586+ locations {
1587+ subnet_crn = ibm_is_subnet.hub_true_sub1.crn
1588+ enabled = true
1589+ }
1590+ locations {
1591+ subnet_crn = ibm_is_subnet.hub_true_sub2.crn
1592+ enabled = true
1593+ }
1594+ }
1595+ // delegated vpc
1596+ resource "ibm_is_vpc" "hub_false_delegated" {
1597+ depends_on = [ibm_dns_custom_resolver.test_hub_true]
1598+ name = "%s"
1599+ dns {
1600+ enable_hub = false
1601+ resolver {
1602+ type = "delegated"
1603+ vpc_crn = ibm_is_vpc.hub_true.crn
1604+ }
1605+ }
1606+ }
1607+
1608+ data "ibm_resource_group" "rg" {
1609+ is_default = true
1610+ }
1611+ ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 )
1612+ }
14081613
14091614// Helper function to generate config for custom resolver with hub VPC
14101615func testAccCheckIBMISVPCCustomResolverDelegatedWithNameConfig (vpcname1 , vpcname2 , dnsName string ) string {
@@ -1468,3 +1673,64 @@ func testAccCheckIBMISVPCCustomResolverDelegatedWithNameConfig(vpcname1, vpcname
14681673 }
14691674 ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 , dnsName )
14701675}
1676+ func testAccCheckIBMISVPCCustomResolverDelegatedWithNameVPCCrnConfig (vpcname1 , vpcname2 , dnsName string ) string {
1677+ return fmt .Sprintf (`
1678+ resource "ibm_is_vpc" "hub_true" {
1679+ name = "%s"
1680+ dns {
1681+ enable_hub = true
1682+ }
1683+ }
1684+ resource "ibm_is_subnet" "hub_true_sub1" {
1685+ name = "hub-true-subnet1"
1686+ vpc = ibm_is_vpc.hub_true.id
1687+ zone = "%s"
1688+ total_ipv4_address_count = 16
1689+ }
1690+ resource "ibm_is_subnet" "hub_true_sub2" {
1691+ name = "hub-true-subnet2"
1692+ vpc = ibm_is_vpc.hub_true.id
1693+ zone = "%s"
1694+ total_ipv4_address_count = 16
1695+ }
1696+ resource "ibm_resource_instance" "dns-cr-instance" {
1697+ name = "dns-cr-instance"
1698+ resource_group_id = data.ibm_resource_group.rg.id
1699+ location = "global"
1700+ service = "dns-svcs"
1701+ plan = "standard-dns"
1702+ }
1703+ resource "ibm_dns_custom_resolver" "test_hub_true" {
1704+ name = "test-hub-true-customresolver"
1705+ instance_id = ibm_resource_instance.dns-cr-instance.guid
1706+ description = "new test CR - TF"
1707+ high_availability = true
1708+ enabled = true
1709+ locations {
1710+ subnet_crn = ibm_is_subnet.hub_true_sub1.crn
1711+ enabled = true
1712+ }
1713+ locations {
1714+ subnet_crn = ibm_is_subnet.hub_true_sub2.crn
1715+ enabled = true
1716+ }
1717+ }
1718+ // delegated vpc
1719+ resource "ibm_is_vpc" "hub_false_delegated" {
1720+ depends_on = [ibm_dns_custom_resolver.test_hub_true]
1721+ name = "%s"
1722+ dns {
1723+ enable_hub = false
1724+ resolver {
1725+ type = "delegated"
1726+ dns_binding_name = "%s"
1727+ vpc_crn = ibm_is_vpc.hub_true.crn
1728+ }
1729+ }
1730+ }
1731+
1732+ data "ibm_resource_group" "rg" {
1733+ is_default = true
1734+ }
1735+ ` , vpcname1 , acc .ISZoneName , acc .ISZoneName , vpcname2 , dnsName )
1736+ }
0 commit comments