Skip to content

Commit d90bc7f

Browse files
hkantarekavya498
authored andcommitted
support parameters for resource instance datasource
1 parent d9ed857 commit d90bc7f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ibm/service/resourcecontroller/data_source_ibm_resource_instance.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package resourcecontroller
55

66
import (
7+
"encoding/json"
78
"fmt"
89
"log"
910
"net/url"
@@ -84,6 +85,12 @@ func DataSourceIBMResourceInstance() *schema.Resource {
8485
Description: "Guid of resource instance",
8586
},
8687

88+
"parameters_json": {
89+
Description: "Parameters asociated with instance in json string",
90+
Type: schema.TypeString,
91+
Computed: true,
92+
},
93+
8794
flex.ResourceName: {
8895
Type: schema.TypeString,
8996
Computed: true,
@@ -246,6 +253,15 @@ func DataSourceIBMResourceInstanceRead(d *schema.ResourceData, meta interface{})
246253
d.Set(flex.ResourceName, instance.Name)
247254
d.Set(flex.ResourceCRN, instance.CRN)
248255
d.Set(flex.ResourceStatus, instance.State)
256+
if instance.Parameters != nil {
257+
params, err := json.Marshal(instance.Parameters)
258+
if err != nil {
259+
return fmt.Errorf("[ERROR] Error marshalling instance parameters: %s", err)
260+
}
261+
if err = d.Set("parameters_json", string(params)); err != nil {
262+
return fmt.Errorf("[ERROR] Error setting instance parameters json: %s", err)
263+
}
264+
}
249265
rMgtClient, err := meta.(conns.ClientSession).ResourceManagerV2API()
250266
if err != nil {
251267
return err

website/docs/d/resource_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ In addition to all argument reference list, you can access the following attribu
4040
- `extensions` - (String) The extended metadata as a map associated with the resource instance.
4141
- `guid`- (String) The GUID of the resource instance.
4242
- `id` - (String) The unique identifier of the resource instance.
43+
- `parameters_json` - (String) The parameters associated with the instance in json format.
4344
- `plan` - (String) The plan for the service offering used by this resource instance.
4445
- `status` - (String) The status of resource instance.

0 commit comments

Comments
 (0)