【发布时间】:2020-02-17 23:09:16
【问题描述】:
如何在 azure 中管理 terraform 状态文件以防止删除和替换, 就像手臂模板一样。 我正在使用 terraform 和 terraform plan 部署 VM,并且应用正在替换 我的虚拟机每次。
【问题讨论】:
如何在 azure 中管理 terraform 状态文件以防止删除和替换, 就像手臂模板一样。 我正在使用 terraform 和 terraform plan 部署 VM,并且应用正在替换 我的虚拟机每次。
【问题讨论】:
您可以从此tutorial 将 Terraform 状态存储在 Azure 存储中,在任何写入状态的操作之前,Azure 存储 blob 都会自动锁定。
如果是这样,您将配置状态后端。 Terraform 状态后端在您运行terraform init 命令时进行配置。配置状态后端需要以下数据:
这是一个例子。
terraform {
backend "azurerm" {
resource_group_name = "tstate"
storage_account_name = "tstate09762"
container_name = "tstate"
key = "terraform.tfstate"
}
}
resource "azurerm_resource_group" "state-demo-secure" {
name = "state-demo"
location = "eastus"
}
【讨论】:
key 并在您的 blob 存储中重新创建一个新的状态文件。这是你所期望的吗?