When importing an existing opensearch index, the captured/imported terraform state doesn't include any indices, which results in a plan/apply for the imported opensearch_index resource replacing the already created index because the alias isn't captured.
How can one reproduce the bug?
Perform a terraform import opensearch_index.my-example-index-v1 my-example-index-v1
Perform a terraform show state opensearch_index.my-example-index-v1.
Look at the output and see that the aliases block is missing for my index with an alias of my-example-index when it's created and shows up in the Opensearch Kibana.
What is the expected behavior?
Performing a terraform import should import any aliases that already exist for opensearch indices.
Output of a terraform show state after performing a terraform import should look like this
What is the bug?
When importing an existing opensearch index, the captured/imported terraform state doesn't include any indices, which results in a plan/apply for the imported opensearch_index resource replacing the already created index because the alias isn't captured.
How can one reproduce the bug?
Perform a
terraform import opensearch_index.my-example-index-v1 my-example-index-v1
Perform aterraform show state opensearch_index.my-example-index-v1
. Look at the output and see that thealiases
block is missing for my index with an alias ofmy-example-index
when it's created and shows up in the Opensearch Kibana.What is the expected behavior?
Performing a terraform import should import any aliases that already exist for opensearch indices. Output of a
terraform show state
after performing aterraform import
should look like thisbut instead performing a
terraform show state opensearch_index.my-example-index-v1
gives this:resulting in a terraform apply replacing the existing index even though the
my-example-index
alias already exists for the index.What is your host/environment?
Docker/k8s, ubuntu base image.
Do you have any additional context?
Add any other context about the problem.