@@ -1346,7 +1346,7 @@ func TestAccIBMISInstanceTemplate_comprehensive(t *testing.T) {
13461346 })
13471347}
13481348
1349- func TestAccIBMISInstanceTemplate_WithAllowedUse (t * testing.T ) {
1349+ func TestAccIBMISInstanceTemplateBoot_WithAllowedUse (t * testing.T ) {
13501350 randInt := acctest .RandIntRange (10 , 100 )
13511351
13521352 publicKey := strings .TrimSpace (`
@@ -1436,3 +1436,99 @@ func testAccCheckIBMISInstanceTemplateWithBoot_AllowedUse(vpcName, subnetName, s
14361436 ` , vpcName , subnetName , acc .ISZoneName , sshKeyName , publicKey , templateName , acc .IsImage , userTag , bandwidth , apiVersion , bareMetalServer , instanceval , acc .ISZoneName )
14371437
14381438}
1439+
1440+ func TestAccIBMISInstanceTemplate_WithAllowedUse (t * testing.T ) {
1441+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
1442+ name := fmt .Sprintf ("tf-instnace-%d" , acctest .RandIntRange (10 , 100 ))
1443+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
1444+ templateName := fmt .Sprintf ("tf-instance-template-%d" , acctest .RandIntRange (10 , 100 ))
1445+ publicKey := strings .TrimSpace (`
1446+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
1447+ ` )
1448+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
1449+ volname := fmt .Sprintf ("tf-vol-%d" , acctest .RandIntRange (10 , 100 ))
1450+ name1 := fmt .Sprintf ("tfsnapshotuat-%d" , acctest .RandIntRange (10 , 100 ))
1451+ apiVersion := "2025-07-01"
1452+ bareMetalServer := "true"
1453+ instanceVal := "true"
1454+ resource .Test (t , resource.TestCase {
1455+ PreCheck : func () { acc .TestAccPreCheck (t ) },
1456+ Providers : acc .TestAccProviders ,
1457+ CheckDestroy : testAccCheckIBMISInstanceTemplateDestroy ,
1458+ Steps : []resource.TestStep {
1459+ {
1460+ Config : testAccCheckIBMISInstanceTemplateWith_AllowedUse (vpcname , subnetname , sshname , publicKey , volname , name , name1 , apiVersion , bareMetalServer , instanceVal , templateName ),
1461+ Check : resource .ComposeTestCheckFunc (
1462+ resource .TestCheckResourceAttr (
1463+ "ibm_is_instance_template.instancetemplate1" , "name" , templateName ),
1464+ // boot volume allowed use
1465+ resource .TestCheckResourceAttrSet (
1466+ "ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.#" ),
1467+ resource .TestCheckResourceAttrSet (
1468+ "ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.bare_metal_server" ),
1469+ resource .TestCheckResourceAttrSet (
1470+ "ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.instance" ),
1471+ resource .TestCheckResourceAttrSet (
1472+ "ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.api_version" ),
1473+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.bare_metal_server" , bareMetalServer ),
1474+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.instance" , instanceVal ),
1475+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "boot_volume.0.allowed_use.0.api_version" , apiVersion ),
1476+
1477+ // volume attchment volume_prototype allowed use
1478+ resource .TestCheckResourceAttrSet (
1479+ "ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.#" ),
1480+ resource .TestCheckResourceAttrSet (
1481+ "ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.bare_metal_server" ),
1482+ resource .TestCheckResourceAttrSet (
1483+ "ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.instance" ),
1484+ resource .TestCheckResourceAttrSet (
1485+ "ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.api_version" ),
1486+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.bare_metal_server" , bareMetalServer ),
1487+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.instance" , instanceVal ),
1488+ resource .TestCheckResourceAttr ("ibm_is_instance_template.instancetemplate1" , "volume_attachments.0.volume_prototype.0.allowed_use.0.api_version" , apiVersion ),
1489+ ),
1490+ },
1491+ },
1492+ })
1493+ }
1494+
1495+ func testAccCheckIBMISInstanceTemplateWith_AllowedUse (vpcname , subnetname , sshname , publicKey , volname , name , sname , apiVersion , bareMetalServer , instanceVal , templateName string ) string {
1496+ return testAccCheckIBMISSnapshotConfigAllowedUse (vpcname , subnetname , sshname , publicKey , volname , name , sname , apiVersion , bareMetalServer , instanceVal ) + fmt .Sprintf (`
1497+ resource "ibm_is_instance_template" "instancetemplate1" {
1498+ name = "%s"
1499+ profile = "bx2-8x32"
1500+ primary_network_interface {
1501+ subnet = ibm_is_subnet.testacc_subnet.id
1502+ }
1503+ boot_volume {
1504+ profile = "general-purpose"
1505+ size = 250
1506+ source_snapshot = ibm_is_snapshot.testacc_snapshot.id
1507+ allowed_use {
1508+ api_version = "%s"
1509+ bare_metal_server = "%s"
1510+ instance = "%s"
1511+ }
1512+ }
1513+ volume_attachments {
1514+ delete_volume_on_instance_delete = true
1515+ name = "volume-attachment-tfp"
1516+ volume_prototype {
1517+ iops = 6000
1518+ profile = "custom"
1519+ capacity = 100
1520+ source_snapshot = ibm_is_snapshot.testacc_snapshot.id
1521+ allowed_use {
1522+ api_version = "%s"
1523+ bare_metal_server = "%s"
1524+ instance = "%s"
1525+ }
1526+ }
1527+ }
1528+ vpc = ibm_is_vpc.testacc_vpc.id
1529+ zone = "%s"
1530+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
1531+ }
1532+ ` , templateName , apiVersion , bareMetalServer , instanceVal , apiVersion , bareMetalServer , instanceVal , acc .ISZoneName )
1533+
1534+ }
0 commit comments