opensearch-project / terraform-provider-opensearch

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

[BUG]: audit config broken with 2.x beta #69

Closed moritzzimmer closed 1 year ago

moritzzimmer commented 1 year ago

What is the bug?

With 2.0.0-beta.1 of the provider, we can't manage our existing Audit logs configuration anymore.

Terraform plan/apply fails with:

╷
│ Error: audit config only available from OpenSearch >= 1.0, got version 2.7.0
│ 
│   with module.logs.opensearch_audit_config.audit[0],
│   on ../../../modules/opensearch/main.tf line 257, in resource "opensearch_audit_config" "audit":
│  257: resource "opensearch_audit_config" "audit" {
│ 
╵

I guess this is related to this version check. AFAIK the /_plugins/_security/api/audit API is supported in 1.x and 2.x of OpenSearch.

How can one reproduce the bug?

Create an opensearch_audit_config resource using the 1.x version of this provider and then try to apply again using 2.0.0-beta.1 (guess creating such a resource with 2.x will fail as well).

What is the expected behavior?

opensearch_audit_config resources can be managed with terraform against OpenSearch 2.x clusters/domains.

What is your host/environment?

AWS OpenSearch domain using 2.7.0 of OpenSearch

{
    "name": "foo",
    "cluster_name": "bar",
    "cluster_uuid": "baz",
    "version": {
        "distribution": "opensearch",
        "number": "2.7.0",
        "build_type": "tar",
        "build_hash": "unknown",
        "build_date": "some-date",
        "build_snapshot": false,
        "lucene_version": "9.5.0",
        "minimum_wire_compatibility_version": "7.10.0",
        "minimum_index_compatibility_version": "7.0.0"
    },
    "tagline": "The OpenSearch Project: https://opensearch.org/"
}
jordarlu commented 1 year ago

@prudhvigodithi , please help take a look ,, thanks CC : @phillbaker

@moritzzimmer , thanks for reporting the issue. While the team is looking into it, please feel free to open a PR if you see any solution for it, and we can review and discuss further.. thanks again !

moritzzimmer commented 1 year ago

@jordarlu PR is ready for review: https://github.com/opensearch-project/terraform-provider-opensearch/pull/73