phillbaker / terraform-provider-elasticsearch

An elasticsearch provider for terraform
https://registry.terraform.io/providers/phillbaker/elasticsearch
Mozilla Public License 2.0
305 stars 134 forks source link

Import of elasticsearch_index misses aliases #184

Open atamgp opened 3 years ago

atamgp commented 3 years ago

When I do an import of my indexes, which have aliases configured (even generated wit the same resource), it's empty in the TF state after import.

In Kibana (firefox) the GET request when listing shows the aliases:

 {
    "19": {
        "health": "green",
        "status": "open",
        "name": "coe-rpa-dataiku-exports-000001",
        "uuid": "9Or6-27sQQelCm93vbrKyw",
        "primary": "1",
        "replica": "1",
        "documents": "0",
        "size": "416b",
        "isFrozen": false,
        "aliases": [
            "coe-rpa-dataiku-exports"
        ],
        "hidden": false,
        "isRollupIndex": false,
        "ilm": {
            "index": "coe-rpa-dataiku-exports-000001",
            "managed": true,
            "policy": "coe-rpa-dataiku-exports",
            "lifecycle_date_millis": 1624000934330,
            "age": "2.98d",
            "phase": "hot",
            "phase_time_millis": 1624000934708,
            "action": "rollover",
            "action_time_millis": 1624000935139,
            "step": "check-rollover-ready",
            "step_time_millis": 1624000935139,
            "phase_execution": {
                "policy": "coe-rpa-dataiku-exports",
                "phase_definition": {
                    "min_age": "0ms",
                    "actions": {
                        "rollover": {
                            "max_size": "40gb",
                            "max_age": "10d"
                        },
                        "set_priority": {
                            "priority": 100
                        }
                    }
                },
                "version": 1,
                "modified_date_in_millis": 1624000933188
            }
        }
    }
}

After import: terragrunt import elasticsearch_index.this[\"dataiku-exports\"] "coe-rpa-dataiku-exports-000001"

this is the state:

"resources": [
    {
      "mode": "managed",
      "type": "elasticsearch_index",
      "name": "this",
      "provider": "provider[\"registry.terraform.io/phillbaker/elasticsearch\"]",
      "instances": [
        {
          "index_key": "dataiku-exports",
          "schema_version": 0,
          "attributes": {
            "aliases": null,
            "auto_expand_replicas": "",
            "codec": "",
            "force_destroy": null,
            "id": "coe-rpa-dataiku-exports-000001",
            "load_fixed_bitset_filters_eagerly": false,
            "mappings": null,
            "name": "coe-rpa-dataiku-exports-000001",
            "number_of_replicas": "1",
            "number_of_shards": "1",
            "refresh_interval": "",
            "rollover_alias": "coe-rpa-dataiku-exports",
            "routing_partition_size": 0
          },
          "sensitive_attributes": [],
          "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
        }
      ]
    },

Because of this, a TF plan will try to recreate an existing imported index..

phillbaker commented 3 years ago

Hello, can you please include the following:

Did this recently stop working or did it never work?

ak58588 commented 3 years ago

Hi! Seems like I am experiencing a similar problem. I need to import some existing elasticsearch indices into the state. They have mappings defined as well as a bunch of other parameters. However, when I do run terraform import, it imports a completely "blank" resource, with all parameters, except for name and id, equal to "null". I am not quite sure, how to import the complete index with its mappings and the other attributes, to further manage this infra using terraform.

falcocoris commented 2 years ago

Hi! Seems like I am experiencing a similar problem. I need to import some existing elasticsearch indices into the state. They have mappings defined as well as a bunch of other parameters. However, when I do run terraform import, it imports a completely "blank" resource, with all parameters, except for name and id, equal to "null". I am not quite sure, how to import the complete index with its mappings and the other attributes, to further manage this infra using terraform.

Hello. I'm having the exact same problem. Everything is null but the name and ID. Did you find a solution for this ?