Skip to content

[Bug] elasticstack_kibana_data_view can't handle different space IDs #530

@mathias-ioki

Description

@mathias-ioki

Describe the bug
When you define a space_id other than "default" in your resource definition, it's ignored and the data view is still created in the default space.

If you define a space_id and data_view.namespaces the resource is created in the right space, but terraform isn't able to verify it, will throw an error and create a duplicate each time terraform runs.

To Reproduce
Steps to reproduce the behavior:

  1. Add a new data view resource, with space_id defined (other than default):
    resource "elasticstack_kibana_data_view" "dataview-backend-staging" {
      space_id = "backend"
      data_view = {
        name = "staging"
        title = "logs-*-staging"
        time_field_name = "@timestamp"
      }
    }
    
  2. Apply the new data view resource
  3. Check the created data view in Kibana. It's created in the default space, not in the backend space.

And the other issue:

  1. Add a new data view resource, with space_id defined (other than default) and namespaces defined:
    resource "elasticstack_kibana_data_view" "dataview-backend-staging" {
      space_id = "backend"
      data_view = {
        name = "staging"
        title = "logs-*-staging"
        namespaces = ["backend"]
        time_field_name = "@timestamp"
      }
    }
    
  2. Apply the new data view resource
  3. The data view is now created in the correct space, but Terraform will throw the error:
     Error: Missing Resource State After Create
    
       with elasticstack_kibana_data_view.dataview-backend-staging,
       on team-backend.tf line 1, in resource "elasticstack_kibana_data_view" "dataview-backend-staging":
        1: resource "elasticstack_kibana_data_view" "dataview-backend-staging" {
    
     The Terraform Provider unexpectedly returned no resource state after having no errors in the resource creation. This is always an issue in the Terraform Provider and should be reported to the provider
     developers.
    
     The resource may have been successfully created, but Terraform is not tracking it. Applying the configuration again with no other action may result in duplicate resource errors.
    

Expected behavior
In both cases, we expect that the data view is created in the defined space, in our case the space is called backend.

Versions (please complete the following information):

  • Terraform Version v1.5.7
  • Provider version v0.11.0
  • Elasticsearch Version 8.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions