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] opensearch_index number_of_replicas is optional but breaks on subsequent applies if unset #52

Open
arichtman-srt opened this issue Jul 12, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@arichtman-srt
Copy link

What is the bug?

Terraform tries to set the number of replicas back to null, which will never work.

How can one reproduce the bug?

  1. Create a resource block of opensearch_index type and set the only required property, name
  2. Apply the Terraform, the index should now be created
  3. Terraform plan, it should show a diff on the property number_of_replicas
  4. Terraform apply, it will fail trying to set number_of_replicas to null

What is the expected behavior?

Either:
A) It's possible to set replica count to nothing, in which case Terraform does so
B) Number of replicas property should be mandatory

What is your host/environment?

$ uname -a && terraform -version

Darwin bne-nb-ariel 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112 arm64 arm Darwin
Terraform v1.3.9
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.7.0
+ provider registry.terraform.io/opensearch-project/opensearch v1.0.0

Your version of Terraform is out of date! The latest version
is 1.5.2. You can update by downloading from https://www.terraform.io/downloads.html

Do you have any screenshots?

image

image

Do you have any additional context?

Technically it's correct that replica count isn't required to create an index. But I'm no software philosopher.

@arichtman-srt arichtman-srt added bug Something isn't working untriaged labels Jul 12, 2023
@peterzhuamazon
Copy link
Member

[Triage] Adding @prudhvigodithi to take a look on this.
Thanks.

@prudhvigodithi
Copy link
Collaborator

Hey @arichtman-srt can you please test with the latest release? https://registry.terraform.io/providers/opensearch-project/opensearch/2.0.0-beta.1
Thank you

@rlanore
Copy link

rlanore commented Dec 14, 2023

Tested today with 2.1.0 and no working with this example:

Example from doc opensearch_index_template resource are not working. I had to update the json.

# Create an index template
resource "opensearch_index_template" "logs_1" {
  name = "logs_1"
  body = <<EOF
{
  "index_patterns": [ "logs*" ],
  "template": {
    "settings": {
      "index": {
        "number_of_shards": "1",
        "number_of_replicas": "0",
        "refresh_interval": "5s"
      }
    }
  }
}
EOF
}

# Create a simple index
resource "opensearch_index" "logs-01" {
  name               = "logs-01"
}

as output

Terraform will perform the following actions:

  # opensearch_index.logs-01 will be updated in-place
  ~ resource "opensearch_index" "logs-01" {
        id                 = "logs-01"
        name               = "logs-01"
      - number_of_replicas = "0" -> null
      - refresh_interval   = "5s" -> null
        # (2 unchanged attributes hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.
opensearch_index.logs-01: Modifying... [id=logs-01]
╷
│ Error: elastic: Error 400 (Bad Request): failed to parse setting [index.refresh_interval] with value [] as a time value: unit is missing or unrecognized [type=illegal_argument_exception]
│
│   with opensearch_index.logs-01,
│   on main.tf line 50, in resource "opensearch_index" "logs-01":
│   50: resource "opensearch_index" "logs-01" {

@rlanore
Copy link

rlanore commented Dec 14, 2023

As a workaround

# Create a simple index
resource "opensearch_index" "logs-01" {
  name               = "logs-01"
  lifecycle {
    ignore_changes = [
      number_of_replicas,
      refresh_interval
    ]
  }
}

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

4 participants