Terraform:如何在 Azure 中为所有容器实施存储帐户管理保留策略,但排除一个特定容器/文件夹?

问题描述 投票:0回答:1

我遵循了 Terraform 文档,其中提到了启用存储保留策略(包括容器/文件夹)的代码 - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_management_policy

但是如何为除一个容器文件夹之外的所有容器启用存储保留策略。我不希望删除此特定容器 1/文件夹 1 下的数据。 我使用了语法 prefix_match != ["container1/folder1", "container2/folder2"],但它不起作用。

      storage_account_id = azurerm_storage_account.example.id

      rule {
        name    = "rule2"
        enabled = true
        filters {
          prefix_match != ["container1/folder1", "container2/folder2"]
          blob_types   = ["blockBlob"]
        }
        actions {
          base_blob {
            tier_to_cool_after_days_since_modification_greater_than    = 11
            tier_to_archive_after_days_since_modification_greater_than = 51
            delete_after_days_since_modification_greater_than          = 101
          }
          snapshot {
            change_tier_to_archive_after_days_since_creation = 90
            change_tier_to_cool_after_days_since_creation    = 23
            delete_after_days_since_creation_greater_than    = 31
          }
          version {
            change_tier_to_archive_after_days_since_creation = 9
            change_tier_to_cool_after_days_since_creation    = 90
            delete_after_days_since_creation                 = 3
          }
        }
       }
    }````

How do I enable storage retention policy for All containers but EXCLUDING one container folder. I do not want the data to get deleted under this specific container1/folder1.
I have used the Syntax prefix_match != ["container1/folder1", "container2/folder2"], But it is not working.
terraform azure-blob-storage terraform-provider-azure
1个回答
0
投票

不幸的是,我认为这是不可能的。 文档指定它忽略

!=

前缀匹配仅考虑正(=)逻辑比较。负 (!=) 逻辑比较将被忽略。

我会推荐给任何一个

  • 将所有要备份的数据放在同一个容器中。
  • 如果不可能,请将要保留且不保留的数据拆分在两个不同的存储帐户中。
© www.soinside.com 2019 - 2024. All rights reserved.