opensearch-project / terraform-provider-opensearch

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

[FEATURE] Support for readonly flag in `opensearch_snapshot_repository` resource #143

Closed shmokmt closed 6 months ago

shmokmt commented 7 months ago

Is your feature request related to a problem?

During the migration of an OpenSearch cluster, preventing write operations on the destination OpenSearch can avoid accidents.

What solution would you like?

I hope readonly flag in opensearch_snapshot_repository resource like below.

# Create a snapshot repository
resource "opensearch_snapshot_repository" "repo" {
  name = "es-index-backups"
  type = "s3"
  settings = {
    bucket   = "es-index-backups"
    region   = "us-east-1"
    role_arn = "arn:aws:iam::123456789012:role/MyRole"
    readonly = true
  }
}

What alternatives have you considered?

A clear and concise description of any alternative solutions or features you've considered.

Do you have any additional context?

prudhvigodithi commented 6 months ago

[Triage] Hey @shmokmt I assume you are looking for the following when readonly = true is added

  "index_settings": {
    "index.blocks.read_only": false
  },

This snapshot feature was added from PR https://github.com/opensearch-project/terraform-provider-opensearch/pull/125, can you please take a look and see if you can contribute ?

Thanks Adding @duboisph @rblcoder @bbarani

duboisph commented 6 months ago

This request is regarding the opensearch_snapshot_repository registering, not Snapshot Management feature added in #125.

That said, looking at the opensearch_snapshot_repository code, this should already work out of the box. The settings map is passed completely to the API.

You can use all settings as allowed by the API, docs: https://opensearch.org/docs/latest/api-reference/snapshots/create-repository/

@shmokmt Have you tried this and isn't it working?

shmokmt commented 6 months ago

I'm sorry. It seems it was my misunderstanding. It worked fine. thanks!