Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support parameters for resource instance datasource #5065

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading