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 being replaced when changes on Aliases #233

Open
TGcandeias opened this issue Jan 31, 2025 · 2 comments
Open

[BUG] Index being replaced when changes on Aliases #233

TGcandeias opened this issue Jan 31, 2025 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@TGcandeias
Copy link

What is the bug?

When updating, adding or removing a alias to an existing Index, terraform will replace the index, instead of performing an update in place.

How can one reproduce the bug?

  1. Create a index with 1 or more aliases using opensearch_index.index
resource "opensearch_index" "index" {
  name = "terraform-index"
  aliases = jsonencode(
    {
      log = {
        is_write_index = true
      }
    }
  )
  number_of_replicas = "0"
  number_of_shards   = "1"
  mappings = file("../.opensearch/testmapping.json")
}
  1. After it has been created update the definition and execute a new plan:

Image

What is the expected behavior?

It is expected for the index to be updated in place instead of being recreated.

What is your host/environment?

Terraform v1.10.3
on windows_amd64

  • provider registry.terraform.io/opensearch-project/opensearch v2.3.1

Do you have any screenshots?

Image

Do you have any additional context?

This was discussed in a previous issue(#85 (comment)), reported fixed on v2.3.1 but till manifests

@prudhvigodithi
Copy link
Member

[Triage]
From my past tests #85 (comment) I see the index alias is updated (some more tests in PR https://github.com/opensearch-project/terraform-provider-opensearch/pull/212/files), I could be wrong but can you try mappings = file without file example and see if you are still seeing the same behavior. Also did are you trying to just update the index or alias details ?

 mappings = jsonencode({
    "properties": {
      "age": {
        "type": "integer"
      }
    }
  })

One more route is can you test with

  1. Create with
 aliases = jsonencode(
    {
      log = {
        is_write_index = true
      }
    }
  )
  1. Remove the aliases.
  2. Now create with
 aliases = jsonencode(
    {
      log3 = {
        is_write_index = true
      }
    }
  )

@getsaurabh02 @rblcoder

@prudhvigodithi prudhvigodithi added good first issue Good for newcomers and removed untriaged labels Feb 14, 2025
@TGcandeias
Copy link
Author

Hi,

Thank you for your reply.

Going over the suggested approach.

Step1
Creating index with 1 alias:

Image

resource "opensearch_index" "index" {
  name = "terraform-index"
  aliases = jsonencode(
    {
      log = {
        is_write_index = true
      }
    }
  )
  number_of_replicas = "0"
  number_of_shards   = "1"
  mappings = jsonencode({
    "properties": {
      "age": {
        "type": "integer"
      }
    }
  })
}

Image


Step2 - Remove alias

resource "opensearch_index" "index" {
  name = "terraform-index"
  number_of_replicas = "0"
  number_of_shards   = "1"
  mappings = jsonencode({
    "properties": {
      "age": {
        "type": "integer"
      }
    }
  })
}

Image

Also performing a direct change on the alias works. The issue seems to be directly related with using a json file to manage the mappings, even when it does not change.

It seems that the culprit is indeed using the file method to provide a json file.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants