【问题标题】:Terraform Backend in azure with managed disks带有托管磁盘的 Azure Terraform 后端
【发布时间】:2018-08-13 04:03:17
【问题描述】:
我们正在从 Azure 中的非托管磁盘迁移到托管磁盘。目前我们的backend.tf定义如下
terraform {
backend "azure" {
storage_account_name = "foo"
container_name = "foo-container"
key = "foo.tfstate"
}
}
使用托管磁盘,您无需引用存储帐户,因为它由 Azure 管理。这对 backend.tf 意味着什么。我们只是删除存储帐户和容器吗?我们是否需要添加一些标志来将后端存储标识为托管? Google 搜索没有提供所需的答案,因此请点击此处。
谢谢
【问题讨论】:
标签:
azure
azure-storage
azure-virtual-machine
terraform
azure-managed-disk
【解决方案1】:
对于托管磁盘,您无需引用存储帐户,因为它
由 Azure 管理。这对 backend.tf 意味着什么。
这意味着你不能使用backend "azure",Azure 托管磁盘不支持这个。
请参考此official document。将状态作为给定键存储在Microsoft Azure Storage 上的给定blob 容器中。
使用 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"
}