diff --git a/ibm/service/vpc/data_source_ibm_is_lb.go b/ibm/service/vpc/data_source_ibm_is_lb.go index 9f3f5f9759..c5ac881419 100644 --- a/ibm/service/vpc/data_source_ibm_is_lb.go +++ b/ibm/service/vpc/data_source_ibm_is_lb.go @@ -402,7 +402,7 @@ func lbGetByName(d *schema.ResourceData, meta interface{}, name string) error { if lb.Logging != nil && lb.Logging.Datapath != nil { d.Set(isLBLogging, *lb.Logging.Datapath.Active) } - if *lb.IsPublic { + if lb.IsPublic != nil && *lb.IsPublic { d.Set(isLBType, "public") } else if lb.IsPrivatePath != nil && *lb.IsPrivatePath { d.Set(isLBType, "private_path") diff --git a/ibm/service/vpc/data_source_ibm_is_lbs.go b/ibm/service/vpc/data_source_ibm_is_lbs.go index 51482b185f..1317588b3f 100644 --- a/ibm/service/vpc/data_source_ibm_is_lbs.go +++ b/ibm/service/vpc/data_source_ibm_is_lbs.go @@ -372,9 +372,9 @@ func getLbs(d *schema.ResourceData, meta interface{}) error { lbInfo[ProvisioningStatus] = *lb.ProvisioningStatus lbInfo[CreatedAt] = lb.CreatedAt.String() - if *lb.IsPublic { + if lb.IsPublic != nil && *lb.IsPublic { lbInfo[isLBType] = "public" - } else if *lb.IsPrivatePath { + } else if lb.IsPrivatePath != nil && *lb.IsPrivatePath { lbInfo[isLBType] = "private_path" } else { lbInfo[isLBType] = "private" diff --git a/ibm/service/vpc/data_source_ibm_is_lbs_test.go b/ibm/service/vpc/data_source_ibm_is_lbs_test.go index 9220036734..55a001ab4e 100644 --- a/ibm/service/vpc/data_source_ibm_is_lbs_test.go +++ b/ibm/service/vpc/data_source_ibm_is_lbs_test.go @@ -30,9 +30,9 @@ func TestAccIBMISLBSDatasource_basic(t *testing.T) { testAccCheckIBMISLBExists("ibm_is_lb.testacc_lb", lb), resource.TestCheckResourceAttr( "data.ibm_is_lb.ds_lb", "name", name), - resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.availability"), - resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.instance_groups_supported"), - resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.source_ip_persistence_supported"), + resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.availability"), + resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.instance_groups_supported"), + resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.source_ip_session_persistence_supported"), ), }, { @@ -101,7 +101,11 @@ func testDSCheckIBMISLBSConfig(vpcname, subnetname, zone, cidr, name string) str } data "ibm_is_lb" "ds_lb" { name = ibm_is_lb.testacc_lb.name - }`, vpcname, subnetname, zone, cidr, name) + } + data "ibm_is_lbs" "test_lbs" { + depends_on = [ibm_is_lb.testacc_lb] + } + `, vpcname, subnetname, zone, cidr, name) } func testDSCheckIBMISLBSDatasourceConfig() string { // status filter defaults to empty diff --git a/ibm/service/vpc/resource_ibm_is_lb.go b/ibm/service/vpc/resource_ibm_is_lb.go index 29dc383459..4606741829 100644 --- a/ibm/service/vpc/resource_ibm_is_lb.go +++ b/ibm/service/vpc/resource_ibm_is_lb.go @@ -574,7 +574,7 @@ func lbGet(d *schema.ResourceData, meta interface{}, id string) error { d.Set("dns", nil) } d.Set(isLBName, *lb.Name) - if *lb.IsPublic { + if lb.IsPublic != nil && *lb.IsPublic { d.Set(isLBType, "public") } else { if lb.IsPrivatePath != nil && *lb.IsPrivatePath {