【发布时间】:2020-01-25 13:58:55
【问题描述】:
所以我使用 terraform for azure provider 来部署我的基础架构。我似乎无法定义存储生命周期。我想添加类似的东西,我发现了,但不能按原样使用。
所以我已经尝试过这个https://github.com/terraform-providers/terraform-provider-azurerm/issues/3316,我已经看遍了。我敢肯定,有一种方法可以告诉 azure 启用生命周期 tiertoarchive 和 tiertodelete……只是似乎无法弄清楚。
谢谢
我在找什么:
*资源 azurerm_storage_management_policy 是一个组成的资源。
resource "azurerm_storage_account" "example" {
name = "myaccount"
resource_group_name = "myresourcegroup"
location = "westeurope"
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_storage_management_policy" "example" {
storage_account_name ="${azurerm_storage_account.example.name}"
rule {
name = "rule1"
enabled = true
type = "Lifecycle"
definition {
filters {
prefix_match = ["container1/wibble"]
blob_types = ["blockBlob"]
}
actions = {
base_blob {
tier_to_cool {
days_after_modification_greater_than = 30
}
tier_to_archive {
days_after_modification_greater_than = 90
}
delete {
days_after_modification_greater_than = 2555
}
snapshot {
delete {
days_after_creation_greater_than = 90
}
}
}
}
}
}
https://github.com/terraform-providers/terraform-provider-azurerm/issues/3316
【问题讨论】:
-
我不确定您是在寻求一种使用 terraform 的方法,还是在 terraform 之外寻求一种方法?因为 tf 现在没有这个功能,所以你总是不得不在门户中做,或者在旁边使用 powershell 或类似的东西,直到 tf 支持它。之后您可以导入它。
-
啊,好吧,我希望能解决使用 terraform 的问题。有没有办法用 PowerShell 做到这一点?我可以为它运行一个脚本吗?可能。我对所有这些基础设施即代码有点陌生
标签: azure azure-storage terraform terraform-provider-azure