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 result after apply #219

Open lukaszpilka opened 2 hours ago

lukaszpilka commented 2 hours ago

What is the bug?

When applying changes to opensearch_dashboard_object resources in multiple tenants, the provider produced inconsistent results after apply. The following error is thrown for random resources, and multiple runs of terraform apply are required to successfully create all resources:

Error: Provider produced inconsistent result after apply

When applying changes to opensearch_dashboard_object, provider "provider[\"registry.terraform.io/opensearch-project/opensearch\"]" produced an unexpected new value: Root resource was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

How can one reproduce the bug?

Define multiple opensearch_dashboard_object in a Terraform configuration. Run terraform apply to create the resources.

Example:

resource "opensearch_dashboard_object" "local_index_pattern_v7" {
  for_each    = var.project_list
  tenant_name = each.key
  body        = <<EOF
[
  {
    "_id": "index-pattern:ck-${lower(each.key)}-local",
    "_source": {
      "type": "index-pattern",
      "index-pattern": {
        "title": "ck-${lower(each.key)}-*",
        "timeFieldName": "@timestamp"
      }
    }
  }
]
EOF

  lifecycle {
    ignore_changes = [body]
  }
}

resource "opensearch_dashboard_object" "global_index_pattern_v7" {
  for_each    = var.project_list
  tenant_name = each.key
  body        = <<EOF
[
  {
    "_id": "index-pattern:ck-${lower(each.key)}-global",
    "_source": {
      "type": "index-pattern",
      "index-pattern": {
        "title": "ck-*",
        "timeFieldName": "@timestamp"
      }
    }
  }
]
EOF

  lifecycle {
    ignore_changes = [body]
  }
}

What is the expected behavior?

All opensearch_dashboard_object resources should be created successfully in a single run of terraform apply without producing inconsistent results.

What is your host/environment?

Operating System: macOS Terraform Version: 1.4 OpenSearch Provider Version: 2.3.1 Do you have any screenshots? image image image

Do you have any additional context?

No.

lukaszpilka commented 2 hours ago

I have similar error when I am destroying these resources. Again, multiple terraform apply runs are required.

image image