Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 19, 2025

Overview

This PR implements a new elasticstack_kibana_default_data_view resource that allows users to programmatically set the default Kibana data view, addressing the feature request in issue #XXX.

Previously, users could only set the default data view manually through the Kibana UI (see screenshot below). This resource enables automated management of this setting through Terraform.

Kibana UI showing "Set as default" button

Changes

New Resource: elasticstack_kibana_default_data_view

Schema:

  • data_view_id (required, string): The data view identifier to set as default
  • force (optional, bool, default: true): Update an existing default data view identifier
  • skip_delete (optional, bool, default: false): If true, the default data view will not be unset when the resource is destroyed

Example Usage:

resource "elasticstack_kibana_data_view" "my_data_view" {
  data_view = {
    title = "my-logs-*"
    name  = "My Logs Data View"
  }
}

resource "elasticstack_kibana_default_data_view" "default" {
  data_view_id = elasticstack_kibana_data_view.my_data_view.data_view.id
  force        = true
  skip_delete  = false
}

Implementation Details

  • API Integration: Uses the Kibana Set Default Data View and Get Default Data View APIs
  • CRUD Operations:
    • Create/Update: Sets the specified data view as default
    • Read: Retrieves and verifies the current default data view
    • Delete: Conditionally unsets the default based on skip_delete flag
  • Framework: Built using the Terraform Plugin Framework (not SDK v2) as per repository guidelines

Files Added

  • internal/kibana/default_data_view/ - Complete resource implementation with CRUD operations, schema, models, and tests
  • examples/resources/elasticstack_kibana_default_data_view/resource.tf - Example configuration
  • docs/resources/kibana_default_data_view.md - Generated documentation

Testing

✅ All acceptance tests pass:

  • Basic create and update functionality
  • Skip delete behavior verification
  • No regressions in existing data_view resource tests

✅ Manual end-to-end testing completed and verified all scenarios:

  • Setting default data view
  • Updating to different data view
  • Conditional deletion behavior

Related Issues

Closes #XXX

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] elasticstack_kibana_data_view - can't set default data view </issue_title>
<issue_description>## Implementation plan

  • Create a new elasticstack_kibana_default_data_view resource
  • Use set default data view and get default data view API operations.
  • The resource should define data_view_id, force, and skip_delete attributes in it's schema. If skip_delete is true then the Delete operation should be a no-op, leaving the existing default data view unchanged.
  • Add acceptance tests covering the resource behaviour. Use the existing elasticstack_kibana_data_view resource to create data views for testing.
  • Ensure you follow the Copilot instructions at all times.

Is your feature request related to a problem? Please describe.
When I have many data views, and I'd like to set only one as a default one.
It's visible in Kibana, in Data view, view:
image

Describe the resource you would like to have implemented.
To be able to manage Kibana automatically, the way I could manually. In case I have a lot of Spaces and DataViews.

Describe the solution you'd like

resource "elasticstack_kibana_data_view" "name" {
  data_view = {
    ...
    default = true
  }
}

Describe alternatives you've considered
REST API Call?

Additional context
Attached screenshot
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #603


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add elasticstack_kibana_default_data_view resource Add elasticstack_kibana_default_data_view resource to manage default data view Oct 19, 2025
Copilot AI requested a review from tobio October 19, 2025 22:57
Copilot finished work on behalf of tobio October 19, 2025 22:57
@tobio tobio force-pushed the copilot/add-default-data-view-resource branch from b9dd33a to 9b64020 Compare October 20, 2025 06:00
@tobio tobio requested a review from nick-benoit October 20, 2025 11:41
@tobio tobio marked this pull request as ready for review October 20, 2025 11:41
tobio added 2 commits October 21, 2025 09:18
…ata-view-resource

* origin/main:
  chore(deps): update golang:1.25.3 docker digest to bce1e7e (#1382)
  Clean before regenerating the client
  Clean before regenerating the client
  Use a working API spec
  chore(deps): update kibana-openapi-spec digest to 9b8ef82 (#1377)
  Include the generated client in the post upgrade task
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.

[Feature] elasticstack_kibana_data_view - can't set default data view

2 participants