Skip to content

Commit

Permalink
fix instance policies to set endpoint type when api url specifies so (#…
Browse files Browse the repository at this point in the history
…5394)

* fix instance policies to set endpoint type when api url specifies so

* Update resource_ibm_kms_instance_policies.go
  • Loading branch information
william8siew authored May 31, 2024
1 parent a42ffe3 commit a2f99ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ibm/service/kms/resource_ibm_kms_instance_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ package kms
import (
"context"
"fmt"
"log"
"time"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate"
kp "github.com/IBM/keyprotect-go-client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
"strings"
"time"
)

func ResourceIBMKmsInstancePolicy() *schema.Resource {
Expand Down Expand Up @@ -259,6 +259,12 @@ func resourceIBMKmsInstancePoliciesRead(context context.Context, d *schema.Resou
setIfNotEmpty("metrics", instancePolicies)
setIfNotEmpty("key_create_import_access", instancePolicies)

if strings.Contains((kpAPI.URL).String(), "private") || strings.Contains(kpAPI.Config.BaseURL, "private") {
d.Set("endpoint_type", "private")
} else {
d.Set("endpoint_type", "public")
}

return nil

}
Expand Down

0 comments on commit a2f99ed

Please sign in to comment.