opensearch-project / terraform-provider-opensearch

https://registry.terraform.io/providers/opensearch-project/opensearch
Apache License 2.0
74 stars 58 forks source link

[BUG]Provider produced inconsistent final plan #183

Open rishabhToshniwal opened 5 months ago

rishabhToshniwal commented 5 months ago

What is the bug?

Provider produced inconsistent final plan when the 'body' value for resource opensearch_component_template changes from plan to apply. In my case the body template would be dynamically fetched from private repo using null_resource. So during plan phase its considering the "{}" value while actually apply returns a JSON template resulting into this issue.

How can one reproduce the bug?

locals{ component_templates_map = {"my-template1": "http://localnexus:8080/mytemplatefile1"} } resource "null_resource" "download_component_templates"{ Downloading file from the local nexus and redirecting the response body into the file }

resource "opensearch_component_template" "component_tempalte" { provider = opensearch.opensearch_provider for_each = local.component_templates_map name = each.key body = try(file("${path.module}/${each.key}_components.json"), "{}") depends_on = [null_resource.download_component_templates] }

Provider opensearch = { source = "opensearch-project/opensearch" version = "2.2.1" }

What is the expected behavior?

Open search component to be created.

What is your host/environment?

Linux

Do you have any screenshots?

image

Do you have any additional context?

Add any other context about the problem.

rblcoder commented 5 months ago

The attribute needs the same value for plan phase and apply phase, hence the error.

rblcoder commented 4 months ago

Further reference from https://github.com/hashicorp/terraform/issues/25090 : The general rule underlying that error is that if the plan for a particular attribute has a known value (anything other than "known after apply") during planning, the value must be exactly the same after the apply phase.

estein9825 commented 1 month ago

I got the error by updating the access rights of the data policy with a new value. Planning showed it was going to update, and it did so at the apply. However it then spit out the error right after. So there is a bug with the read after the update.

nidnogg commented 1 month ago

+1 on this, it is quite the struggle to get this piece working with AWS OpenSearch right now.

estein9825 commented 1 month ago

If I then try rerunning it again, I get this error:

ValidationException: No changes detected in policy or policy description