@@ -4010,3 +4010,190 @@ func testAccCheckIBMISInstanceVolumeBandwidthConfig(vpcname, subnetname, sshname
40104010 keys = [ibm_is_ssh_key.testacc_sshkey.id]
40114011 }` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , name , acc .IsImage , acc .InstanceProfileName , bandwidtth , userData , acc .ISZoneName )
40124012}
4013+
4014+ // tdx testing
4015+
4016+ func TestAccIBMISInstanceTDX_basic (t * testing.T ) {
4017+ var instance string
4018+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
4019+ name := fmt .Sprintf ("tf-instance-%d" , acctest .RandIntRange (10 , 100 ))
4020+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
4021+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
4022+ publicKey := strings .TrimSpace (`
4023+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
4024+ ` )
4025+
4026+ resource .Test (t , resource.TestCase {
4027+ PreCheck : func () { acc .TestAccPreCheck (t ) },
4028+ Providers : acc .TestAccProviders ,
4029+ CheckDestroy : testAccCheckIBMISInstanceDestroy ,
4030+ Steps : []resource.TestStep {
4031+ {
4032+ Config : testAccCheckIBMISInstanceConfigTDX (vpcname , subnetname , sshname , publicKey , name ),
4033+ Check : resource .ComposeTestCheckFunc (
4034+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance" , instance ),
4035+ resource .TestCheckResourceAttr (
4036+ "ibm_is_instance.testacc_instance" , "name" , name ),
4037+ resource .TestCheckResourceAttr (
4038+ "ibm_is_instance.testacc_instance" , "confidential_compute_mode" , "tdx" ),
4039+ resource .TestCheckResourceAttr (
4040+ "ibm_is_instance.testacc_instance" , "profile" , "bx3dc-2x10" ),
4041+ resource .TestCheckResourceAttr (
4042+ "ibm_is_instance.testacc_instance" , "zone" , acc .ISZoneName ),
4043+ ),
4044+ },
4045+ },
4046+ })
4047+ }
4048+
4049+ func TestAccIBMISInstanceSGXtoTDX_basic (t * testing.T ) {
4050+ var instance string
4051+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
4052+ name := fmt .Sprintf ("tf-instance-%d" , acctest .RandIntRange (10 , 100 ))
4053+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
4054+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
4055+ publicKey := strings .TrimSpace (`
4056+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
4057+ ` )
4058+
4059+ resource .Test (t , resource.TestCase {
4060+ PreCheck : func () { acc .TestAccPreCheck (t ) },
4061+ Providers : acc .TestAccProviders ,
4062+ CheckDestroy : testAccCheckIBMISInstanceDestroy ,
4063+ Steps : []resource.TestStep {
4064+ {
4065+ Config : testAccCheckIBMISInstanceConfigSGX (vpcname , subnetname , sshname , publicKey , name ),
4066+ Check : resource .ComposeTestCheckFunc (
4067+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance" , instance ),
4068+ resource .TestCheckResourceAttr (
4069+ "ibm_is_instance.testacc_instance" , "name" , name ),
4070+ resource .TestCheckResourceAttr (
4071+ "ibm_is_instance.testacc_instance" , "confidential_compute_mode" , "sgx" ),
4072+ resource .TestCheckResourceAttr (
4073+ "ibm_is_instance.testacc_instance" , "profile" , "bx3dc-2x10" ),
4074+ ),
4075+ },
4076+ {
4077+ Config : testAccCheckIBMISInstanceActionStopSGX (vpcname , subnetname , sshname , publicKey , name ),
4078+ Check : resource .ComposeTestCheckFunc (
4079+ resource .TestCheckResourceAttr (
4080+ "ibm_is_instance_action.testacc_instanceaction" , "action" , "stop" ),
4081+ ),
4082+ },
4083+ {
4084+ Config : testAccCheckIBMISInstanceConfigTDX (vpcname , subnetname , sshname , publicKey , name ),
4085+ Check : resource .ComposeTestCheckFunc (
4086+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance" , instance ),
4087+ resource .TestCheckResourceAttr (
4088+ "ibm_is_instance.testacc_instance" , "name" , name ),
4089+ resource .TestCheckResourceAttr (
4090+ "ibm_is_instance.testacc_instance" , "confidential_compute_mode" , "tdx" ),
4091+ resource .TestCheckResourceAttr (
4092+ "ibm_is_instance.testacc_instance" , "profile" , "bx3dc-2x10" ),
4093+ ),
4094+ },
4095+ },
4096+ })
4097+ }
4098+
4099+ func testAccCheckIBMISInstanceConfigSGX (vpcname , subnetname , sshname , publicKey , name string ) string {
4100+ return fmt .Sprintf (`
4101+ resource "ibm_is_vpc" "testacc_vpc" {
4102+ name = "%s"
4103+ }
4104+
4105+ resource "ibm_is_subnet" "testacc_subnet" {
4106+ name = "%s"
4107+ vpc = ibm_is_vpc.testacc_vpc.id
4108+ zone = "%s"
4109+ ipv4_cidr_block = "%s"
4110+ }
4111+
4112+ resource "ibm_is_ssh_key" "testacc_sshkey" {
4113+ name = "%s"
4114+ public_key = "%s"
4115+ }
4116+
4117+ resource "ibm_is_instance" "testacc_instance" {
4118+ name = "%s"
4119+ image = "%s"
4120+ profile = "bx3dc-2x10"
4121+ confidential_compute_mode = "sgx"
4122+ primary_network_interface {
4123+ subnet = ibm_is_subnet.testacc_subnet.id
4124+ }
4125+ vpc = ibm_is_vpc.testacc_vpc.id
4126+ zone = "%s"
4127+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
4128+ }` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , name , acc .IsImage , acc .ISZoneName )
4129+ }
4130+
4131+ func testAccCheckIBMISInstanceActionStopSGX (vpcname , subnetname , sshname , publicKey , name string ) string {
4132+ return fmt .Sprintf (`
4133+ resource "ibm_is_vpc" "testacc_vpc" {
4134+ name = "%s"
4135+ }
4136+
4137+ resource "ibm_is_subnet" "testacc_subnet" {
4138+ name = "%s"
4139+ vpc = ibm_is_vpc.testacc_vpc.id
4140+ zone = "%s"
4141+ ipv4_cidr_block = "%s"
4142+ }
4143+
4144+ resource "ibm_is_ssh_key" "testacc_sshkey" {
4145+ name = "%s"
4146+ public_key = "%s"
4147+ }
4148+
4149+ resource "ibm_is_instance" "testacc_instance" {
4150+ name = "%s"
4151+ image = "%s"
4152+ profile = "bx3dc-2x10"
4153+ confidential_compute_mode = "sgx"
4154+ primary_network_interface {
4155+ subnet = ibm_is_subnet.testacc_subnet.id
4156+ }
4157+ vpc = ibm_is_vpc.testacc_vpc.id
4158+ zone = "%s"
4159+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
4160+ }
4161+
4162+ resource "ibm_is_instance_action" "testacc_instanceaction" {
4163+ depends_on = [ibm_is_instance.testacc_instance]
4164+ action = "stop"
4165+ instance = ibm_is_instance.testacc_instance.id
4166+ }` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , name , acc .IsImage , acc .ISZoneName )
4167+ }
4168+
4169+ func testAccCheckIBMISInstanceConfigTDX (vpcname , subnetname , sshname , publicKey , name string ) string {
4170+ return fmt .Sprintf (`
4171+ resource "ibm_is_vpc" "testacc_vpc" {
4172+ name = "%s"
4173+ }
4174+
4175+ resource "ibm_is_subnet" "testacc_subnet" {
4176+ name = "%s"
4177+ vpc = ibm_is_vpc.testacc_vpc.id
4178+ zone = "%s"
4179+ ipv4_cidr_block = "%s"
4180+ }
4181+
4182+ resource "ibm_is_ssh_key" "testacc_sshkey" {
4183+ name = "%s"
4184+ public_key = "%s"
4185+ }
4186+
4187+ resource "ibm_is_instance" "testacc_instance" {
4188+ name = "%s"
4189+ image = "%s"
4190+ profile = "bx3dc-2x10"
4191+ confidential_compute_mode = "tdx"
4192+ primary_network_interface {
4193+ subnet = ibm_is_subnet.testacc_subnet.id
4194+ }
4195+ vpc = ibm_is_vpc.testacc_vpc.id
4196+ zone = "%s"
4197+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
4198+ }` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , name , acc .IsImage , acc .ISZoneName )
4199+ }
0 commit comments