@@ -57,9 +57,15 @@ func TestAccIBMISInstanceBootVolumeManager_basic(t *testing.T) {
5757
5858func TestAccIBMISInstanceBootVolumeManager_capacity_update (t * testing.T ) {
5959 var vol string
60- tag1 := "env:prod"
61- tag2 := "boot:unattached"
62- tag3 := "delete:false"
60+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
61+ name := fmt .Sprintf ("tf-server-%d" , acctest .RandIntRange (10 , 100 ))
62+ subnetname := fmt .Sprintf ("tfip-subnet-%d" , acctest .RandIntRange (10 , 100 ))
63+ capacity0 := int64 (0 )
64+ capacity := int64 (180 )
65+ publicKey := strings .TrimSpace (`
66+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
67+ ` )
68+ sshname := fmt .Sprintf ("tf-sshname-%d" , acctest .RandIntRange (10 , 100 ))
6369 resource .Test (t , resource.TestCase {
6470 PreCheck : func () { acc .TestAccPreCheck (t ) },
6571 Providers : acc .TestAccProviders ,
@@ -92,7 +98,7 @@ func TestAccIBMISInstanceBootVolumeManager_capacity_update(t *testing.T) {
9298 ),
9399 },
94100 {
95- Config : testAccCheckIBMISInstanceBootVolumeManagerTagUpdateConfig ( tag1 , tag2 , "" ),
101+ Config : testAccCheckIBMISInstanceBootVolumeManagerCapacityUpdateConfig ( vpcname , subnetname , sshname , publicKey , name , capacity0 ),
96102 Check : resource .ComposeTestCheckFunc (
97103 testAccCheckIBMISVolumeExists ("ibm_is_instance_boot_volume_manager.boot" , vol ),
98104 resource .TestCheckResourceAttrSet (
@@ -116,11 +122,10 @@ func TestAccIBMISInstanceBootVolumeManager_capacity_update(t *testing.T) {
116122 resource .TestCheckResourceAttrSet (
117123 "ibm_is_instance_boot_volume_manager.boot" , "zone" ),
118124 resource .TestCheckResourceAttrSet ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" ),
119- resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" , "3" ),
120125 ),
121126 },
122127 {
123- Config : testAccCheckIBMISInstanceBootVolumeManagerTagUpdateConfig ( tag1 , tag2 , tag3 ),
128+ Config : testAccCheckIBMISInstanceBootVolumeManagerCapacityUpdateConfig ( vpcname , subnetname , sshname , publicKey , name , capacity ),
124129 Check : resource .ComposeTestCheckFunc (
125130 testAccCheckIBMISVolumeExists ("ibm_is_instance_boot_volume_manager.boot" , vol ),
126131 resource .TestCheckResourceAttrSet (
@@ -144,17 +149,23 @@ func TestAccIBMISInstanceBootVolumeManager_capacity_update(t *testing.T) {
144149 resource .TestCheckResourceAttrSet (
145150 "ibm_is_instance_boot_volume_manager.boot" , "zone" ),
146151 resource .TestCheckResourceAttrSet ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" ),
147- resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "tags.# " , "3" ),
152+ resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "capacity " , fmt . Sprintf ( "%d" , capacity ) ),
148153 ),
149154 },
150155 },
151156 })
152157}
153- func TestAccIBMISInstanceBootVolumeManager_iops_update (t * testing.T ) {
158+ func TestAccIBMISInstanceBootVolumeManager_profile_update (t * testing.T ) {
154159 var vol string
155- tag1 := "env:prod"
156- tag2 := "boot:unattached"
157- tag3 := "delete:false"
160+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
161+ name := fmt .Sprintf ("tf-server-%d" , acctest .RandIntRange (10 , 100 ))
162+ subnetname := fmt .Sprintf ("tfip-subnet-%d" , acctest .RandIntRange (10 , 100 ))
163+ profile0 := ""
164+ profile := "10iops-tier"
165+ publicKey := strings .TrimSpace (`
166+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
167+ ` )
168+ sshname := fmt .Sprintf ("tf-sshname-%d" , acctest .RandIntRange (10 , 100 ))
158169 resource .Test (t , resource.TestCase {
159170 PreCheck : func () { acc .TestAccPreCheck (t ) },
160171 Providers : acc .TestAccProviders ,
@@ -187,7 +198,7 @@ func TestAccIBMISInstanceBootVolumeManager_iops_update(t *testing.T) {
187198 ),
188199 },
189200 {
190- Config : testAccCheckIBMISInstanceBootVolumeManagerTagUpdateConfig ( tag1 , tag2 , "" ),
201+ Config : testAccCheckIBMISInstanceBootVolumeManagerProfileUpdateConfig ( vpcname , subnetname , sshname , publicKey , name , profile0 ),
191202 Check : resource .ComposeTestCheckFunc (
192203 testAccCheckIBMISVolumeExists ("ibm_is_instance_boot_volume_manager.boot" , vol ),
193204 resource .TestCheckResourceAttrSet (
@@ -211,11 +222,10 @@ func TestAccIBMISInstanceBootVolumeManager_iops_update(t *testing.T) {
211222 resource .TestCheckResourceAttrSet (
212223 "ibm_is_instance_boot_volume_manager.boot" , "zone" ),
213224 resource .TestCheckResourceAttrSet ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" ),
214- resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" , "3" ),
215225 ),
216226 },
217227 {
218- Config : testAccCheckIBMISInstanceBootVolumeManagerTagUpdateConfig ( tag1 , tag2 , tag3 ),
228+ Config : testAccCheckIBMISInstanceBootVolumeManagerProfileUpdateConfig ( vpcname , subnetname , sshname , publicKey , name , profile ),
219229 Check : resource .ComposeTestCheckFunc (
220230 testAccCheckIBMISVolumeExists ("ibm_is_instance_boot_volume_manager.boot" , vol ),
221231 resource .TestCheckResourceAttrSet (
@@ -239,12 +249,13 @@ func TestAccIBMISInstanceBootVolumeManager_iops_update(t *testing.T) {
239249 resource .TestCheckResourceAttrSet (
240250 "ibm_is_instance_boot_volume_manager.boot" , "zone" ),
241251 resource .TestCheckResourceAttrSet ("ibm_is_instance_boot_volume_manager.boot" , "tags.#" ),
242- resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "tags.# " , "3" ),
252+ resource .TestCheckResourceAttr ("ibm_is_instance_boot_volume_manager.boot" , "profile " , profile ),
243253 ),
244254 },
245255 },
246256 })
247257}
258+
248259func TestAccIBMISInstanceBootVolumeManager_all_update (t * testing.T ) {
249260 var vol string
250261 tag1 := "env:prod"
@@ -726,7 +737,7 @@ func testAccCheckIBMISInstanceBootVolumeManagerAccessTagUpdateConfig(tag1 string
726737
727738}
728739
729- func testAccCheckIBMISInstanceBootVolumeManagerTierConfig (vpcname , subnetname , sshname , publicKey , name , volName , profileName string ) string {
740+ func testAccCheckIBMISInstanceBootVolumeManagerCapacityUpdateConfig (vpcname , subnetname , sshname , publicKey , name string , capacity int64 ) string {
730741 return fmt .Sprintf (
731742 `
732743 resource "ibm_is_vpc" "testacc_vpc" {
@@ -744,44 +755,31 @@ func testAccCheckIBMISInstanceBootVolumeManagerTierConfig(vpcname, subnetname, s
744755 name = "%s"
745756 public_key = "%s"
746757 }
747- resource "ibm_is_volume" "storage"{
748- name = "%s"
749- profile = "%s"
750- zone = "%s"
751- }
758+
752759 resource "ibm_is_instance" "testacc_instance" {
753760 name = "%s"
754- image = "%s"
755761 profile = "%s"
756- volumes = [ibm_is_instance_boot_volume_manager.boot.id]
762+ boot_volume {
763+ volume_id = ibm_is_instance_boot_volume_manager.boot.id
764+ auto_delete_volume = false
765+ }
757766 primary_network_interface {
758767 subnet = ibm_is_subnet.testacc_subnet.id
759768 }
760769 vpc = ibm_is_vpc.testacc_vpc.id
761770 zone = "%s"
762771 keys = [ibm_is_ssh_key.testacc_sshkey.id]
763- }
764-
765- ` , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , volName , profileName , acc .ISZoneName , name , acc .IsImage , acc .InstanceProfileName , acc .ISZoneName )
772+ }
773+ resource "ibm_is_instance_boot_volume_manager" "boot" {
774+ volume_id = "%s"
775+ capacity = %d == 0 ? null : %d
776+ }
777+ ` , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , name , acc .InstanceProfileName , acc .ISZoneName , acc .VSIUnattachedBootVolumeID , capacity , capacity )
766778
767779}
768-
769- func testAccCheckIBMISInstanceBootVolumeManagerAttachmentDeleteConfig (vpcname , subnetname , sshname , publicKey , insname , capacityArray string ) string {
780+ func testAccCheckIBMISInstanceBootVolumeManagerProfileUpdateConfig (vpcname , subnetname , sshname , publicKey , name , profile string ) string {
770781 return fmt .Sprintf (
771782 `
772- variable "vsi_vol_size" {
773- description = "capacity array"
774- default = %s
775- }
776-
777- resource "ibm_is_volume" "storage"{
778- name = "tf-vol-att-${count.index}"
779- count = length(var.vsi_vol_size)
780- profile = "general-purpose"
781- zone = "%s"
782- capacity = var.vsi_vol_size[count.index]
783- }
784-
785783 resource "ibm_is_vpc" "testacc_vpc" {
786784 name = "%s"
787785 }
@@ -794,29 +792,48 @@ func testAccCheckIBMISInstanceBootVolumeManagerAttachmentDeleteConfig(vpcname, s
794792 }
795793
796794 resource "ibm_is_ssh_key" "testacc_sshkey" {
797- name = "%s"
798- public_key = "%s"
795+ name = "%s"
796+ public_key = "%s"
799797 }
800-
798+
801799 resource "ibm_is_instance" "testacc_instance" {
802- name = "%s"
803- image = "%s"
804- profile = "%s"
805- volumes = ibm_is_instance_boot_volume_manager.boot[*].id
800+ name = "%s"
801+ profile = "%s"
802+ boot_volume {
803+ volume_id = ibm_is_instance_boot_volume_manager.boot.id
804+ auto_delete_volume = false
805+ }
806806 primary_network_interface {
807807 subnet = ibm_is_subnet.testacc_subnet.id
808808 }
809809 vpc = ibm_is_vpc.testacc_vpc.id
810810 zone = "%s"
811811 keys = [ibm_is_ssh_key.testacc_sshkey.id]
812812 }
813- ` , capacityArray , acc .ISZoneName , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , insname , acc .IsImage , acc .InstanceProfileName , acc .ISZoneName )
813+ resource "ibm_is_instance_boot_volume_manager" "boot" {
814+ volume_id = "%s"
815+ profile = "%s" == "" ? null : "%s"
816+ }
817+ ` , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , name , acc .InstanceProfileName , acc .ISZoneName , acc .VSIUnattachedBootVolumeID , profile , profile )
814818
815819}
816820
817- func testAccCheckIBMISInstanceBootVolumeManagerCapacityConfig (vpcname , subnetname , sshname , publicKey , name , volName string , capacity int64 ) string {
821+ func testAccCheckIBMISInstanceBootVolumeManagerAttachmentDeleteConfig (vpcname , subnetname , sshname , publicKey , insname , capacityArray string ) string {
818822 return fmt .Sprintf (
819823 `
824+ variable "vsi_vol_size" {
825+ description = "capacity array"
826+ default = %s
827+ }
828+
829+ resource "ibm_is_volume" "storage"{
830+ name = "tf-vol-att-${count.index}"
831+ count = length(var.vsi_vol_size)
832+ profile = "general-purpose"
833+ zone = "%s"
834+ capacity = var.vsi_vol_size[count.index]
835+ }
836+
820837 resource "ibm_is_vpc" "testacc_vpc" {
821838 name = "%s"
822839 }
@@ -829,29 +846,23 @@ func testAccCheckIBMISInstanceBootVolumeManagerCapacityConfig(vpcname, subnetnam
829846 }
830847
831848 resource "ibm_is_ssh_key" "testacc_sshkey" {
832- name = "%s"
833- public_key = "%s"
849+ name = "%s"
850+ public_key = "%s"
834851 }
835- resource "ibm_is_volume" "storage"{
836- name = "%s"
837- profile = "10iops-tier"
838- zone = "%s"
839- capacity = %d
840- }
852+
841853 resource "ibm_is_instance" "testacc_instance" {
842- name = "%s"
843- image = "%s"
844- profile = "%s"
845- volumes = [ ibm_is_instance_boot_volume_manager.boot.id]
854+ name = "%s"
855+ image = "%s"
856+ profile = "%s"
857+ volumes = ibm_is_instance_boot_volume_manager.boot[*] .id
846858 primary_network_interface {
847859 subnet = ibm_is_subnet.testacc_subnet.id
848860 }
849861 vpc = ibm_is_vpc.testacc_vpc.id
850862 zone = "%s"
851863 keys = [ibm_is_ssh_key.testacc_sshkey.id]
852- }
853-
854- ` , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , volName , acc .ISZoneName , capacity , name , acc .IsImage , acc .InstanceProfileName , acc .ISZoneName )
864+ }
865+ ` , capacityArray , acc .ISZoneName , vpcname , subnetname , acc .ISZoneName , sshname , publicKey , insname , acc .IsImage , acc .InstanceProfileName , acc .ISZoneName )
855866
856867}
857868
0 commit comments