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] Import of index resource doesn't include mapping configuration #135

Closed
jmaitrehenry opened this issue Dec 15, 2023 · 6 comments
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jmaitrehenry
Copy link

What is the bug?

When I attempt to import the opensearch_index resource with mapping configured, it doesn't get imported into the state

How can one reproduce the bug?

Create an index with a mapping configuration:

resource opensearch_index "my-index" {
	name               = "my-index"
	mappings           = file("${path.module}/elasticsearch-mappings/my-index.mapping.json")
	number_of_replicas = 1
	number_of_shards   = 5
}

Remove it from the state and import it back:

terragrunt state rm opensearch_index.my-index
terragrunt import opensearch_index.enriched-contacts my-index

The new resource state doesn't have the mapping configuration:

terragrunt state show opensearch_index.my-index
# opensearch_index.my-index:
resource "opensearch_index" "my-index" {
    id                 = "my-index"
    name               = "my-index"
    number_of_replicas = "1"
    number_of_shards   = "5"
}

What is the expected behavior?

The mapping is imported.

What is your host/environment?

Provider:

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.26.0"
    }

    opensearch = {
      source = "opensearch-project/opensearch"
      version = "2.1.0"
    }
  }

Terraform:

Terraform v1.5.7
on darwin_arm64
@jmaitrehenry jmaitrehenry added bug Something isn't working untriaged labels Dec 15, 2023
@prudhvigodithi
Copy link
Member

[Untriage]
Hey @jmaitrehenry thanks for reporting, looks to me like this is a similar issue #71, if you are open can you please contribute and fix this bug?
Thank you
Adding @rblcoder

@prudhvigodithi prudhvigodithi added good first issue Good for newcomers and removed untriaged labels Dec 20, 2023
@rblcoder
Copy link
Collaborator

rblcoder commented Jan 7, 2024

@prudhvigodithi When I try to call

mapping, err := osClient.GetMapping().Index(index).Do(ctx)

err shows elastic: Error 400 (Bad Request)

Variable index contains the name of the index.

@xsnrg
Copy link

xsnrg commented Jan 11, 2024

My issue for this was closed referencing #71 . What are the chances of getting somebody on the core team to fix this? I don't know that the community has any PR work ready for fixing it, and it is fairly important to the usability of the provider.

@prudhvigodithi
Copy link
Member

prudhvigodithi commented Jan 11, 2024

Hey @xsnrg when you mention core team are you referencing to the OpenSearch core engine and should a fix happen in core engine or can a fix be part of the terraform provider ?
Adding @bbarani @phillbaker

@xsnrg
Copy link

xsnrg commented Jan 11, 2024

@prudhvigodithi - a good question. My understanding is the fix is needed in the provider. I was referring to the primary contributors to the terraform-provider-opensearch project, and not to the actual Opensearch core engine team.

There are individuals here that are more familiar with the provider code, such as @bbarani and @phillbaker . They could probably knock this out fairly quickly if they have the time, vs. waiting for a community member to provide a PR. My hope is somebody close to the provider code could take a look and see if it is a quick win.

@prudhvigodithi
Copy link
Member

I can see the PR #145 merged (thanks to @rblcoder) that should allow importing of index mapping. If still seeing issues for importing index mappings using opensearch_index, we can re-open this. @xsnrg @jmaitrehenry.

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: ✅ Done
Development

No branches or pull requests

4 participants