天蓝色的 Terraform 后端与托管磁盘

Terraform Backend in azure with managed disks

我们正在从 Azure 中的非托管磁盘迁移到托管磁盘。目前我们的backend.tf定义如下

terraform {
  backend "azure" {
    storage_account_name = "foo"
    container_name = "foo-container"
    key = "foo.tfstate"
  }
}

对于托管磁盘,您没有对存储帐户的引用,因为它是由 Azure 管理的。这对 backend.tf 意味着什么。我们是否只删除存储帐户和容器?我们是否需要添加一些标志来将后端存储标识为托管存储? Google 搜索未产生所需答案,因此请联系此处。

谢谢

With managed disks you don't have reference to storage account as it is managed by Azure. What does this mean for backend.tf.

这意味着您无法使用backend "azure",Azure 托管磁盘不支持此功能。

请参考这个official document.Stores the state as a given key in a given blob container on Microsoft Azure Storage

使用 terraform 创建托管磁盘你可以检查这个 link

resource "azurerm_managed_disk" "test" {
  name = "acctestmd"
  location = "West US 2"
  resource_group_name = "${azurerm_resource_group.test.name}"
  storage_account_type = "Standard_LRS"
  create_option = "Empty"
  disk_size_gb = "1"

  tags {
    environment = "staging"
  }