terraform-provider-opensearch icon indicating copy to clipboard operation
terraform-provider-opensearch copied to clipboard

[BUG]Provider produced inconsistent final plan

Open rishabhToshniwal opened this issue 10 months ago • 5 comments

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.

rishabhToshniwal avatar Apr 23 '24 20:04 rishabhToshniwal

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

rblcoder avatar May 06 '24 11:05 rblcoder

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.

rblcoder avatar May 17 '24 08:05 rblcoder

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.

estein9825 avatar Sep 04 '24 20:09 estein9825

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

nidnogg avatar Sep 04 '24 20:09 nidnogg

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

ValidationException: No changes detected in policy or policy description

estein9825 avatar Sep 04 '24 20:09 estein9825