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

[Bug] Index settings not being imported to terraform #53

Closed
fdvieira-td opened this issue Jan 31, 2022 · 1 comment · Fixed by #55
Closed

[Bug] Index settings not being imported to terraform #53

fdvieira-td opened this issue Jan 31, 2022 · 1 comment · Fixed by #55
Assignees
Labels
bug Something isn't working Elasticsearch Elasticsearch related APIs

Comments

@fdvieira-td
Copy link

Describe the bug
Hey guys 👋 We've found a bug in the provider when using resource "elasticstack_elasticsearch_index" where this resource does not import the existing index settings to terraform.

To Reproduce
Steps to reproduce the behavior:

  1. TF configuration used. Create a new index with alias, mappings and settings manually:
{
    "dummy": {
        "aliases": {
            "dummy1": {}
        },
        "mappings": {
            "properties": {
                "field1": {
                    "type": "text"
                }
            }
        },
        "settings": {
            "index": {
                "creation_date": "1643651976221",
                "number_of_shards": "3",
                "number_of_replicas": "2",
                "uuid": "cluster-uuid",
                "version": {
                    "created": "7090199"
                },
                "provided_name": "dummy"
            }
        }
    }
}
  1. Add the configuration of this index to terraform.
  # module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"] will be created
  + resource "elasticstack_elasticsearch_index" "this" {
      + id           = (known after apply)
      + mappings     = jsonencode(
            {
              + properties = {
                  + field1 = {
                      + type = "text"
                    }
                }
            }
        )
      + name         = "dummy"
      + settings_raw = (known after apply)

      + alias {
          + is_hidden      = false
          + is_write_index = false
          + name           = "dummy1"
        }

      + settings {
          + setting {
              + name  = "index.number_of_replicas"
              + value = "2"
            }
          + setting {
              + name  = "index.number_of_shards"
              + value = "3"
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
  1. Import the index to terraform by running
 terraform import 'module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"]' 'cluster-uuid/dummy' 
  1. The output of the command is as follows:
module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"]: Importing from ID "cluster-uuid/dummy"...
module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"]: Import prepared!
  Prepared elasticstack_elasticsearch_index for import
module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"]: Refreshing state... [id=cluster-uuid/dummy]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
  1. Run terraform plan and the output says that the settings will be created:
  # module.elasticsearch_indices.elasticstack_elasticsearch_index.this["dummy"] will be updated in-place
  ~ resource "elasticstack_elasticsearch_index" "this" {
        id           = "cluster-uuid/dummy"
        name         = "dummy"
        # (2 unchanged attributes hidden)


      + settings {
          + setting {
              + name  = "index.number_of_replicas"
              + value = "2"
            }
          + setting {
              + name  = "index.number_of_shards"
              + value = "3"
            }
          + setting {
              + name  = "index.refresh_interval"
              + value = "30s"
            }
        }
        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Expected behavior
I would expect that the index settings were imported into the terraform state.

Debug output
Run terraform command with TF_LOG=trace and provide extended information on TF operations. -> No different output with the TRACE operation.

Screenshots
Not applicable.

Desktop (please complete the following information):

  • OS: macOS Big Sur
  • Terraform Version v1.0.11
  • Provider version 0.2.0.

Additional context
Add any other context about the problem here.

If you need any clarification or more details please let me know.
By the way, awesome work with this provider 💪
Francisco

@fdvieira-td fdvieira-td added the bug Something isn't working label Jan 31, 2022
@olksdr olksdr self-assigned this Feb 1, 2022
@olksdr olksdr added the Elasticsearch Elasticsearch related APIs label Feb 1, 2022
@olksdr olksdr closed this as completed in #55 Feb 2, 2022
@olksdr
Copy link
Contributor

olksdr commented Feb 17, 2022

New version of the provider released: v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Elasticsearch Elasticsearch related APIs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants