diff --git a/builtin/providers/opc/resource_instance.go b/builtin/providers/opc/resource_instance.go index 686ff7b0a..7e413b13f 100644 --- a/builtin/providers/opc/resource_instance.go +++ b/builtin/providers/opc/resource_instance.go @@ -80,6 +80,7 @@ func resourceInstance() *schema.Resource { "label": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, diff --git a/builtin/providers/opc/resource_instance_test.go b/builtin/providers/opc/resource_instance_test.go index a29f08c8d..d2371110f 100644 --- a/builtin/providers/opc/resource_instance_test.go +++ b/builtin/providers/opc/resource_instance_test.go @@ -136,6 +136,27 @@ func TestAccOPCInstance_storage(t *testing.T) { }) } +func TestAccOPCInstance_emptyLabel(t *testing.T) { + resName := "opc_compute_instance.test" + rInt := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccOPCCheckInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccInstanceEmptyLabel(rInt), + Check: resource.ComposeTestCheckFunc( + testAccOPCCheckInstanceExists, + resource.TestCheckResourceAttr(resName, "name", fmt.Sprintf("acc-test-instance-%d", rInt)), + resource.TestCheckResourceAttrSet(resName, "label"), + ), + }, + }, + }) +} + func testAccOPCCheckInstanceExists(s *terraform.State) error { client := testAccProvider.Meta().(*compute.Client).Instances() @@ -271,3 +292,17 @@ resource "opc_compute_instance" "test" { } }`, rInt, rInt, rInt) } + +func testAccInstanceEmptyLabel(rInt int) string { + return fmt.Sprintf(` +resource "opc_compute_instance" "test" { + name = "acc-test-instance-%d" + shape = "oc3" + image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300" + instance_attributes = <