@@ -182,6 +182,32 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
182182 })
183183}
184184
185+ func TestAccIBMISInstance_metadata_service (t * testing.T ) {
186+ var instance string
187+ vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
188+ name := fmt .Sprintf ("tf-instnace-%d" , acctest .RandIntRange (10 , 100 ))
189+ subnetname := fmt .Sprintf ("tf-subnet-%d" , acctest .RandIntRange (10 , 100 ))
190+ publicKey := strings .TrimSpace (`
191+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
192+ ` )
193+ sshname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
194+
195+ resource .Test (t , resource.TestCase {
196+ PreCheck : func () { testAccPreCheck (t ) },
197+ Providers : testAccProviders ,
198+ CheckDestroy : testAccCheckIBMISInstanceDestroy ,
199+ Steps : []resource.TestStep {
200+ {
201+ Config : testAccCheckIBMISInstanceWithMetaConfig (vpcname , subnetname , sshname , publicKey , name , true ),
202+ Check : resource .ComposeTestCheckFunc (
203+ testAccCheckIBMISInstanceExists ("ibm_is_instance.testacc_instance" , instance ),
204+ resource .TestCheckResourceAttr (
205+ "ibm_is_instance.testacc_instance" , "metadata_service_enabled" , "true" ),
206+ ),
207+ },
208+ },
209+ })
210+ }
185211func TestAccIBMISInstance_profile (t * testing.T ) {
186212 var instance string
187213 vpcname := fmt .Sprintf ("tf-vpc-%d" , acctest .RandIntRange (10 , 100 ))
@@ -538,6 +564,42 @@ func testAccCheckIBMISInstanceExists(n string, instance string) resource.TestChe
538564 }
539565}
540566
567+ func testAccCheckIBMISInstanceWithMetaConfig (vpcname , subnetname , sshname , publicKey , name string , metadata_service_enabled bool ) string {
568+ return fmt .Sprintf (`
569+ resource "ibm_is_vpc" "testacc_vpc" {
570+ name = "%s"
571+ }
572+
573+ resource "ibm_is_subnet" "testacc_subnet" {
574+ name = "%s"
575+ vpc = ibm_is_vpc.testacc_vpc.id
576+ zone = "%s"
577+ ipv4_cidr_block = "%s"
578+ }
579+
580+ resource "ibm_is_ssh_key" "testacc_sshkey" {
581+ name = "%s"
582+ public_key = "%s"
583+ }
584+
585+ resource "ibm_is_instance" "testacc_instance" {
586+ name = "%s"
587+ image = "%s"
588+ profile = "%s"
589+ primary_network_interface {
590+ subnet = ibm_is_subnet.testacc_subnet.id
591+ }
592+ vpc = ibm_is_vpc.testacc_vpc.id
593+ zone = "%s"
594+ keys = [ibm_is_ssh_key.testacc_sshkey.id]
595+ network_interfaces {
596+ subnet = ibm_is_subnet.testacc_subnet.id
597+ name = "eth1"
598+ }
599+ metadata_service_enabled=%v
600+ }` , vpcname , subnetname , ISZoneName , ISCIDR , sshname , publicKey , name , isImage , instanceProfileName , ISZoneName , metadata_service_enabled )
601+ }
602+
541603func testAccCheckIBMISInstanceConfig (vpcname , subnetname , sshname , publicKey , name string ) string {
542604 return fmt .Sprintf (`
543605 resource "ibm_is_vpc" "testacc_vpc" {
0 commit comments