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] Terraform state for opensearch_index resource should include aliases on import #190

Open
thejettanderson opened this issue May 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@thejettanderson
Copy link

thejettanderson commented May 20, 2024

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 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

resource "opensearch_index" "my-example-index-v1" {
  id               = "my-example-index-v1"
  aliases      = jsonencode(
    {
      "my-example-index" = {}
    }
  )
  mappings = jsonencode(
    {
      ...
    }
  )
}

but instead performing a terraform show state opensearch_index.my-example-index-v1 gives this:

resource "opensearch_index" "my-example-index-v1" {
  id               = "my-example-index-v1"
  mappings = jsonencode(
    {
      ...
    }
  )
}

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.

@thejettanderson thejettanderson added bug Something isn't working untriaged labels May 20, 2024
@dblock
Copy link
Member

dblock commented Jun 24, 2024

Catch All Triage - 1 2 3 4 5 6

@prudhvigodithi
Copy link
Collaborator

prudhvigodithi commented Sep 17, 2024

Hey @thejettanderson AFAIK this PR i have created #212 should fix the issue. The logic is added to the PR to update the index alias. More details #85 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants