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

Add kibana_saved_object resource #948

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ydubreuil
Copy link
Member

This PR implements proper support for managing a Kibana saved object.

Unlike existing resource kibana_import_saved_objects, this new resource can only manage one single saved object but it keeps track of the changes, if the resource is changed in the Terraform code or in Kibana, the TF plan will show the difference. It also supports removing the saved object.

Providing support for all CRUD operations is required to expose this resource in a Crossplane provider.

This PR has been tested both with Terraform and with a Crossplane provider that relies on this code.

internal/kibana/saved_object/read.go Show resolved Hide resolved
},
"object": schema.StringAttribute{
Description: "Kibana object to import in JSON format",
Required: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Required: true,
Required: true,
CustomType: jsontypes.NormalizedType{},

The index resource has an example of using this. It means simply restructuring the JSON won't be seen as a diff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for pointing that out

return
}

result, err := kibanaClient.KibanaSavedObject.Import([]byte(model.Imported.ValueString()), false, model.SpaceID.ValueString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result, err := kibanaClient.KibanaSavedObject.Import([]byte(model.Imported.ValueString()), false, model.SpaceID.ValueString())
result, err := kibanaClient.KibanaSavedObject.Import([]byte(model.Imported.ValueString()), true, model.SpaceID.ValueString())

Given the use case here, I wonder if we should just always overwrite existing objects. It would simplify the workflow for bringing existing objects into TF, especially in a resource where a proper import handler is kind of tricky given the API constraints.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about that and initially had overwrite set to true. I agree it would simplify importing resources into TF to have it set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants