opensearch-project / terraform-provider-opensearch

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

[BUG] opensearch_ism_policy_mapping deprecated resource? #144

Closed gscho closed 5 months ago

gscho commented 7 months ago

What is the bug?

When using the opensearch_ism_policy_mapping I'm told it is a deprecated resource. The message on how to remediate the issue is unclear.

The message says:

please use ism_template attribute in policies instead

I cannot figure out which resource has this attribute or how to fix this deprecation.

│ Warning: Deprecated Resource
│
│   with module.opensearch_index_management.opensearch_ism_policy_mapping.opensearch,
│   on ../../../modules/opensearch-index-management/policy_mappings.tf line 7, in resource "opensearch_ism_policy_mapping" "opensearch":
│    7: resource "opensearch_ism_policy_mapping" "opensearch" {
│
│ opensearch_ism_policy_mapping is deprecated in Opensearch 1.x please use ism_template attribute in policies instead.

How can one reproduce the bug?

What is the expected behavior?

The message should tell me how to remediate the deprecation in a clear and concise manner.

What is your host/environment?

terraform {
  required_providers {
    opensearch = {
      source  = "opensearch-project/opensearch"
      version = "2.2.0"
    }
  }
}
Wyifei commented 7 months ago

same issue with AWS OpenSearch 2.7 image

prudhvigodithi commented 6 months ago

[Triage] There was an question raised before by @mo-saeed https://github.com/opensearch-project/terraform-provider-opensearch/issues/40, did you declare ism_template in the policy ? https://opensearch.org/docs/latest/im-plugin/ism/policies/ Adding @phillbaker who initially contributed to this ism mapping.

@Wyifei, @gscho can you share your policy tf file you are applying ? Also some reference here https://github.com/opensearch-project/terraform-provider-opensearch/issues/83#issue-1904552280.

Adding @bbarani @rblcoder

gscho commented 6 months ago

@prudhvigodithi I think the message could be made more clear. Something like:

"opensearch_ism_policy_mapping is deprecated in Opensearch 1.x please use the opensearch_ism_policy resource and specify the ism_template attribute in the policies instead."

I am specifying that attribute in my policy so I suspect if I switch to using the opensearch_ism_policy resource instead it would remove the deprecation warning.

My policy:

{
    "policy": {
        "description": "delete_after_7d",
        "default_state": "hot",
        "states": [
            {
                "name": "hot",
                "actions": [],
                "transitions": [
                    {
                        "state_name": "cold",
                        "conditions": {
                            "min_index_age": "3d"
                        }
                    }
                ]
            },
            {
                "name": "cold",
                "actions": [],
                "transitions": [
                    {
                        "state_name": "to_delete",
                        "conditions": {
                            "min_index_age": "7d"
                        }
                    }
                ]
            },
            {
                "name": "to_delete",
                "actions": [
                    {
                        "retry": {
                            "count": 3,
                            "backoff": "exponential",
                            "delay": "1m"
                        },
                        "delete": {}
                    }
                ],
                "transitions": []
            }
        ],
        "ism_template": [
            {
                "index_patterns": [
                    "${index_pattern}"
                ],
                "priority": 1
            }
        ]
    }
}
loru88 commented 5 months ago

The message is also visibile in the documentation provider, see #166

I think this ticket can be closed

prudhvigodithi commented 5 months ago

Thanks @loru88 , closing this issue. @rblcoder @bbarani