@@ -4562,3 +4562,134 @@ func testAccCheckIBMISInstanceConfig_AllowedUse(vpcname, subnetname, sshname, pu
45624562 }
45634563 ` , insName , acc .InstanceProfileName , acc .ISZoneName , apiVersion , bareMetalServer , instanceval , apiVersion , bareMetalServer , instanceval )
45644564}
4565+
4566+ // shared core
4567+
4568+ func TestAccIBMISInstance_vcpu (t * testing.T ) {
4569+ var instance string
4570+
4571+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
4572+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
4573+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
4574+ prefix := fmt .Sprintf ("tf-%d" , acctest .RandIntRange (10 , 100 ))
4575+
4576+ publicKey := strings .TrimSpace (`
4577+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
4578+ ` )
4579+
4580+ resource .Test (t , resource.TestCase {
4581+ PreCheck : func () { acc .TestAccPreCheck (t ) },
4582+ Providers : acc .TestAccProviders ,
4583+ CheckDestroy : testAccCheckIBMISInstanceDestroy ,
4584+ Steps : []resource.TestStep {
4585+ {
4586+ Config : testAccCheckIBMISInstanceVCPUConfig (vpcname , subnetname , sshname , publicKey , prefix ),
4587+ Check : resource .ComposeTestCheckFunc (
4588+ testAccCheckIBMISInstanceExists ("ibm_is_instance.is_instance" , instance ),
4589+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "name" , fmt .Sprintf ("%s-ins" , prefix )),
4590+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "vcpu.0.percentage" , "100" ),
4591+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "vcpu.0.tenancy" , "dedicated" ),
4592+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "reservation_affinity.0.policy" , "disabled" ),
4593+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "zone" , acc .ISZoneName ),
4594+ resource .TestCheckResourceAttrSet ("ibm_is_instance.is_instance" , "primary_network_attachment.0.name" ),
4595+ ),
4596+ },
4597+ {
4598+ Config : testAccCheckIBMISInstanceVCPUConfigUpdate (vpcname , subnetname , sshname , publicKey , prefix ),
4599+ Check : resource .ComposeTestCheckFunc (
4600+ testAccCheckIBMISInstanceExists ("ibm_is_instance.is_instance" , instance ),
4601+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "name" , fmt .Sprintf ("%s-ins" , prefix )),
4602+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "vcpu.0.percentage" , "25" ),
4603+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "vcpu.0.tenancy" , "shared" ),
4604+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "reservation_affinity.0.policy" , "disabled" ),
4605+ resource .TestCheckResourceAttr ("ibm_is_instance.is_instance" , "zone" , acc .ISZoneName ),
4606+ resource .TestCheckResourceAttrSet ("ibm_is_instance.is_instance" , "primary_network_attachment.0.name" ),
4607+ ),
4608+ },
4609+ },
4610+ })
4611+ }
4612+
4613+ func testAccCheckIBMISInstanceVCPUConfig (vpcname , subnetname , sshname , publicKey , prefix string ) string {
4614+ return fmt .Sprintf (`
4615+ resource "ibm_is_vpc" "vpc1" {
4616+ name = "%s"
4617+ }
4618+
4619+ resource "ibm_is_subnet" "subnet1" {
4620+ name = "%s"
4621+ vpc = ibm_is_vpc.vpc1.id
4622+ zone = "%s"
4623+ ipv4_cidr_block = "%s"
4624+ }
4625+
4626+ resource "ibm_is_ssh_key" "is_key" {
4627+ name = "%s"
4628+ public_key = "%s"
4629+ }
4630+
4631+ resource "ibm_is_instance" "is_instance" {
4632+ name = "%s-ins"
4633+ image = "%s"
4634+ profile = "%s"
4635+ vpc = ibm_is_vpc.vpc1.id
4636+ zone = ibm_is_subnet.subnet1.zone
4637+ keys = [ibm_is_ssh_key.is_key.id]
4638+ primary_network_attachment {
4639+ name = "%s-pna2"
4640+ virtual_network_interface {
4641+ subnet = ibm_is_subnet.subnet1.id
4642+ }
4643+ }
4644+ reservation_affinity {
4645+ policy = "disabled"
4646+ }
4647+ vcpu {
4648+ percentage = 100
4649+ tenancy = "dedicated"
4650+ }
4651+ }
4652+ ` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , prefix , acc .IsImage , acc .InstanceProfileName , prefix )
4653+ }
4654+
4655+ func testAccCheckIBMISInstanceVCPUConfigUpdate (vpcname , subnetname , sshname , publicKey , prefix string ) string {
4656+ return fmt .Sprintf (`
4657+ resource "ibm_is_vpc" "vpc1" {
4658+ name = "%s"
4659+ }
4660+
4661+ resource "ibm_is_subnet" "subnet1" {
4662+ name = "%s"
4663+ vpc = ibm_is_vpc.vpc1.id
4664+ zone = "%s"
4665+ ipv4_cidr_block = "%s"
4666+ }
4667+
4668+ resource "ibm_is_ssh_key" "is_key" {
4669+ name = "%s"
4670+ public_key = "%s"
4671+ }
4672+
4673+ resource "ibm_is_instance" "is_instance" {
4674+ name = "%s-ins"
4675+ image = "%s"
4676+ profile = "%s"
4677+ vpc = ibm_is_vpc.vpc1.id
4678+ zone = ibm_is_subnet.subnet1.zone
4679+ keys = [ibm_is_ssh_key.is_key.id]
4680+ primary_network_attachment {
4681+ name = "%s-pna2"
4682+ virtual_network_interface {
4683+ subnet = ibm_is_subnet.subnet1.id
4684+ }
4685+ }
4686+ reservation_affinity {
4687+ policy = "disabled"
4688+ }
4689+ vcpu {
4690+ percentage = 25
4691+ tenancy = "shared"
4692+ }
4693+ }
4694+ ` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , prefix , acc .IsImage , acc .InstanceProfileName , prefix )
4695+ }
0 commit comments