Skip to content

Commit

Permalink
support parameters for resource instance datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare authored and kavya498 committed Jan 20, 2024
1 parent d9ed857 commit d90bc7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package resourcecontroller

import (
"encoding/json"
"fmt"
"log"
"net/url"
Expand Down Expand Up @@ -84,6 +85,12 @@ func DataSourceIBMResourceInstance() *schema.Resource {
Description: "Guid of resource instance",
},

"parameters_json": {
Description: "Parameters asociated with instance in json string",
Type: schema.TypeString,
Computed: true,
},

flex.ResourceName: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -246,6 +253,15 @@ func DataSourceIBMResourceInstanceRead(d *schema.ResourceData, meta interface{})
d.Set(flex.ResourceName, instance.Name)
d.Set(flex.ResourceCRN, instance.CRN)
d.Set(flex.ResourceStatus, instance.State)
if instance.Parameters != nil {
params, err := json.Marshal(instance.Parameters)
if err != nil {
return fmt.Errorf("[ERROR] Error marshalling instance parameters: %s", err)
}
if err = d.Set("parameters_json", string(params)); err != nil {
return fmt.Errorf("[ERROR] Error setting instance parameters json: %s", err)
}
}
rMgtClient, err := meta.(conns.ClientSession).ResourceManagerV2API()
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/resource_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ In addition to all argument reference list, you can access the following attribu
- `extensions` - (String) The extended metadata as a map associated with the resource instance.
- `guid`- (String) The GUID of the resource instance.
- `id` - (String) The unique identifier of the resource instance.
- `parameters_json` - (String) The parameters associated with the instance in json format.
- `plan` - (String) The plan for the service offering used by this resource instance.
- `status` - (String) The status of resource instance.

0 comments on commit d90bc7f

Please sign in to comment.