-
Notifications
You must be signed in to change notification settings - Fork 60
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 the opensearch_index resource does not include the analysis attributes #225
Comments
gonz-cint
changed the title
[BUG] Import of the index resource does not include the analysis attributes
[BUG] Import of the opensearch_index resource does not include the analysis attributes
Dec 9, 2024
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Issues Resolved
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Signed-off-by: Gonzalo Arce <[email protected]>
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Signed-off-by: Gonzalo Arce <[email protected]>
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Signed-off-by: Gonzalo Arce <[email protected]>
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Signed-off-by: Gonzalo Arce <[email protected]>
gonz-cint
added a commit
to gonz-cint/terraform-provider-opensearch
that referenced
this issue
Dec 11, 2024
Previously, when importing an existing index, the analysis configuration (analyzers, tokenizers, filters, char_filters, and normalizers) was not fully populated into the Terraform state. As a result, users would not see these analysis settings after import, leading to missing or incomplete configurations in state. This commit introduces logic to reconstruct nested analysis objects from the flattened `index.analysis.*` keys returned by OpenSearch on import. By converting these flattened keys back into a nested JSON structure, the imported index state now includes the analysis settings as users typically define them in their Terraform configuration. **Note**: This change may reveal differences for existing configurations if they rely on unquoted numeric values or trailing whitespace in analysis-related JSON. Such configurations may now produce diffs where they did not before, potentially resulting in forced replacements. Signed-off-by: Gonzalo Arce <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the bug?
When importing an
opensearch_index
resource using theOpenSearch
provider for Terraform, the analysis attributes (e.g.,analysis_analyzer
,analysis_tokenizer
,analysis_filter
,analysis_char_filter
) are not included in the state of the imported resource. As a result, Terraform sees these as differences and forces the resource to be replaced during the next plan/apply cycle.How can one reproduce the bug?
1- Create an OpenSearch index resource with analysis attributes (e.g., analyzers, tokenizers, filters).
2- Import the resource using the OpenSearch provider for Terraform (terraform import or the import block).
3- Run terraform state show on the imported resource and notice that the analysis attributes are missing.
4- Run terraform plan to compare the imported resource against the configuration, and observe that Terraform plans to replace the resource because the analysis attributes are seen as missing.
What is the expected behavior?
When importing an OpenSearch index resource, all attributes, including analysis attributes, should be correctly imported into the state. Terraform should not force replacement of the resource if the imported resource matches the configuration.
What is your host/environment?
Terraform version:
1.8.5
OpenSearch provider version:
2.3.1
OpenSearch version:
2.13
Do you have any additional context?
The following index was imported into the state running
terraform import
:Configuration Block:
the analysis objects do exist in the resource already, however after importing this is the output of
terraform state show
:Therefore a plan triggers an index replacement, as it sees the analysis objects as additions:
The text was updated successfully, but these errors were encountered: