Skip to content

Commit

Permalink
Support update of parameters for resource instance #1705
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare committed Sep 25, 2020
1 parent d14ca3c commit 0b550dc
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions ibm/resource_ibm_resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func resourceIBMResourceInstance() *schema.Resource {
"parameters": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Description: "Arbitrary parameters to pass. Must be a JSON object",
},

Expand Down Expand Up @@ -119,6 +118,7 @@ func resourceIBMResourceInstance() *schema.Resource {
Description: "Types of the service endpoints. Possible values are 'public', 'private', 'public-and-private'.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateAllowedStringValue([]string{"public", "private", "public-and-private"}),
},
"dashboard_url": {
Expand Down Expand Up @@ -397,13 +397,34 @@ func resourceIBMResourceInstanceUpdate(d *schema.ResourceData, meta interface{})
params := map[string]interface{}{}

if d.HasChange("service_endpoints") {
params["service-endpoints"] = d.Get("service_endpoints").(string)
endpoint := d.Get("service_endpoints").(string)
params["service-endpoints"] = endpoint
}

if d.HasChange("parameters") {
param := d.Get("parameters").(map[string]interface{})
for k, v := range param {
params[k] = v
instance, err := rsConClient.ResourceServiceInstance().GetInstance(instanceID)
if err != nil {
return fmt.Errorf("Error retrieving resource instance: %s", err)
}

if parameters, ok := d.GetOk("parameters"); ok {
temp := parameters.(map[string]interface{})
for k, v := range temp {
if v == "true" || v == "false" {
b, _ := strconv.ParseBool(v.(string))
params[k] = b

} else {
params[k] = v
}
}
}
serviceEndpoints := d.Get("service_endpoints").(string)
if serviceEndpoints != "" {
endpoint := d.Get("service_endpoints").(string)
params["service-endpoints"] = endpoint
} else if _, ok := instance.Parameters["service-endpoints"]; ok {
params["service-endpoints"] = instance.Parameters["service-endpoints"]
}

}
Expand Down

0 comments on commit 0b550dc

Please sign in to comment.