@@ -4633,3 +4633,148 @@ func testAccCheckIBMISInstanceConfig_AllowedUse(vpcname, subnetname, sshname, pu
46334633 }
46344634 ` , insName , acc .InstanceProfileName , acc .ISZoneName , apiVersion , bareMetalServer , instanceval , apiVersion , bareMetalServer , instanceval )
46354635}
4636+
4637+ // boot volume profile test
4638+
4639+ func TestAccIBMISInstance_BootVolumeVariations (t * testing.T ) {
4640+ var instance string
4641+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
4642+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
4643+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
4644+ templatename := fmt .Sprintf ("tf-template-%d" , acctest .RandIntRange (10 , 100 ))
4645+ sourceInstanceName := fmt .Sprintf ("tf-instance-source-%d" , acctest .RandIntRange (10 , 100 ))
4646+ instanceFromTemplateName := fmt .Sprintf ("tf-instance-template-%d" , acctest .RandIntRange (10 , 100 ))
4647+ instanceFromCatalogName := fmt .Sprintf ("tf-instance-catalog-%d" , acctest .RandIntRange (10 , 100 ))
4648+ snapshotname := fmt .Sprintf ("tf-snapshot-%d" , acctest .RandIntRange (10 , 100 ))
4649+ instanceFromSnapshotName := fmt .Sprintf ("tf-instance-snapshot-%d" , acctest .RandIntRange (10 , 100 ))
4650+ publicKey := strings .TrimSpace (`
4651+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
4652+ ` )
4653+
4654+ resource .Test (t , resource.TestCase {
4655+ PreCheck : func () { acc .TestAccPreCheck (t ) },
4656+ Providers : acc .TestAccProviders ,
4657+ CheckDestroy : testAccCheckIBMISInstanceDestroy ,
4658+ Steps : []resource.TestStep {
4659+ {
4660+ Config : testAccCheckIBMISInstanceBootVolumeConfig (vpcname , subnetname , sshname , publicKey , templatename , sourceInstanceName , snapshotname , instanceFromTemplateName , instanceFromCatalogName , instanceFromSnapshotName ),
4661+ Check : resource .ComposeTestCheckFunc (
4662+ // Verify instance from template with boot volume
4663+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance_template" , instance ),
4664+ resource .TestCheckResourceAttr (
4665+ "ibm_is_instance.testacc_instance_template" , "name" , instanceFromTemplateName ),
4666+ resource .TestCheckResourceAttrSet (
4667+ "ibm_is_instance.testacc_instance_template" , "instance_template" ),
4668+ resource .TestCheckResourceAttr (
4669+ "ibm_is_instance.testacc_instance_template" , "boot_volume.0.profile" , "sdp" ),
4670+ resource .TestCheckResourceAttrSet (
4671+ "ibm_is_instance.testacc_instance_template" , "boot_volume.0.name" ),
4672+ resource .TestCheckResourceAttrSet (
4673+ "ibm_is_instance.testacc_instance_template" , "primary_network_attachment.0.id" ),
4674+ resource .TestCheckResourceAttr (
4675+ "ibm_is_instance.testacc_instance_template" , "zone" , acc .ISZoneName ),
4676+
4677+ // Verify instance from catalog with boot volume
4678+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance_catalog" , instance ),
4679+ resource .TestCheckResourceAttr (
4680+ "ibm_is_instance.testacc_instance_catalog" , "name" , instanceFromCatalogName ),
4681+ resource .TestCheckResourceAttr (
4682+ "ibm_is_instance.testacc_instance_catalog" , "boot_volume.0.profile" , "sdp" ),
4683+ resource .TestCheckResourceAttrSet (
4684+ "ibm_is_instance.testacc_instance_catalog" , "boot_volume.0.name" ),
4685+ resource .TestCheckResourceAttrSet (
4686+ "ibm_is_instance.testacc_instance_catalog" , "catalog_offering.0.version_crn" ),
4687+ resource .TestCheckResourceAttrSet (
4688+ "ibm_is_instance.testacc_instance_catalog" , "primary_network_attachment.0.id" ),
4689+ resource .TestCheckResourceAttr (
4690+ "ibm_is_instance.testacc_instance_catalog" , "zone" , acc .ISZoneName ),
4691+ ),
4692+ },
4693+ },
4694+ })
4695+ }
4696+
4697+ func testAccCheckIBMISInstanceBootVolumeConfig (vpcname , subnetname , sshname , publicKey , templatename , sourceInstanceName , snapshotname , instanceFromTemplateName , instanceFromCatalogName , instanceFromSnapshotName string ) string {
4698+ return fmt .Sprintf (`
4699+ resource "ibm_is_vpc" "testacc_vpc" {
4700+ name = "%s"
4701+ }
4702+
4703+ resource "ibm_is_subnet" "testacc_subnet" {
4704+ name = "%s"
4705+ vpc = ibm_is_vpc.testacc_vpc.id
4706+ zone = "%s"
4707+ total_ipv4_address_count = 64
4708+ }
4709+
4710+ resource "ibm_is_ssh_key" "testacc_sshkey" {
4711+ name = "%s"
4712+ public_key = "%s"
4713+ }
4714+
4715+ resource "ibm_is_instance_template" "instancetemplate1" {
4716+ name = "%s"
4717+ image = "%s"
4718+ profile = "bxf-2x8"
4719+ primary_network_attachment {
4720+ name = "pna-template"
4721+ virtual_network_interface {
4722+ subnet = ibm_is_subnet.testacc_subnet.id
4723+ }
4724+ }
4725+ vpc = ibm_is_vpc.testacc_vpc.id
4726+ zone = "%s"
4727+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
4728+ }
4729+
4730+ resource "ibm_is_instance" "testacc_instance_source" {
4731+ name = "%s"
4732+ primary_network_attachment {
4733+ name = "pna-from-template"
4734+ virtual_network_interface {
4735+ subnet = ibm_is_subnet.testacc_subnet.id
4736+ }
4737+ }
4738+ instance_template = ibm_is_instance_template.instancetemplate1.id
4739+ }
4740+
4741+ resource "ibm_is_instance" "testacc_instance_template" {
4742+ name = "%s"
4743+ boot_volume {
4744+ profile = "sdp"
4745+ }
4746+ primary_network_attachment {
4747+ name = "pna-ins-from-template"
4748+ virtual_network_interface {
4749+ subnet = ibm_is_subnet.testacc_subnet.id
4750+ }
4751+ }
4752+ instance_template = ibm_is_instance_template.instancetemplate1.id
4753+ }
4754+
4755+ data "ibm_is_image" "catalog_image" {
4756+ name = "%s"
4757+ }
4758+
4759+ resource "ibm_is_instance" "testacc_instance_catalog" {
4760+ name = "%s"
4761+ profile = "bxf-2x8"
4762+ primary_network_attachment {
4763+ name = "pna-catalog"
4764+ virtual_network_interface {
4765+ subnet = ibm_is_subnet.testacc_subnet.id
4766+ }
4767+ }
4768+ boot_volume {
4769+ profile = "sdp"
4770+ }
4771+ catalog_offering {
4772+ version_crn = data.ibm_is_image.catalog_image.catalog_offering.0.version.0.crn
4773+ }
4774+ vpc = ibm_is_vpc.testacc_vpc.id
4775+ zone = ibm_is_subnet.testacc_subnet.zone
4776+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
4777+ }
4778+
4779+ ` , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , templatename , acc .IsImage , acc .ISZoneName , sourceInstanceName , instanceFromTemplateName , acc .ISCatalogImageName , instanceFromCatalogName )
4780+ }
0 commit comments