使用 Terraform 进行增量更新
Incremental update with terraform
我在 orcastrating 我的 Azure 环境中使用 Terraform。目前我可以执行增量更新。当我 运行 一个新计划时,它试图破坏所有以前的;y 应用的资源。例如,我创建了一个新的虚拟机,接下来我 运行 一个创建角色的新计划,它将虚拟机标记为销毁。
我知道 Azure ARM 的部署模式为 incremental
或 complete
。
是否可以从 terraform 访问 deployment_mode
属性?
例如,在这个脚本中:
data "azurerm_subscription" "primary" {
}
resource "azurerm_role_definition" "roles" {
count = length(var.roles)
name = "${var.role_prefix}${var.roles[count.index]["suffix_name"]}${var.role_suffix}"
scope = "${data.azurerm_subscription.primary.id}"
permissions {
actions = split(",", var.roles[count.index]["actions"])
not_actions = split(",", var.roles[count.index]["not_actions"])
}
assignable_scopes = ["${data.azurerm_subscription.primary.id}"]
}
有没有办法设置deployment_mode
?
您误解了 terraform 的工作原理。它只会在无法编辑资源时销毁资源。如果编辑可行(至少 Terraform 应该认为它可行),Terraform 将只更新服务,但在您创建资源后许多东西是不可变的(名称是一个很好的例子)。简而言之:如果您尝试更改不可变 属性(或者更准确地说 - 属性 terraform 认为它是不可变的)terraform 将 destroy\create 资源,否则它将更新它。
此外,您误解了 complete\incremental 部署模式 ;)
我在 orcastrating 我的 Azure 环境中使用 Terraform。目前我可以执行增量更新。当我 运行 一个新计划时,它试图破坏所有以前的;y 应用的资源。例如,我创建了一个新的虚拟机,接下来我 运行 一个创建角色的新计划,它将虚拟机标记为销毁。
我知道 Azure ARM 的部署模式为 incremental
或 complete
。
是否可以从 terraform 访问 deployment_mode
属性?
例如,在这个脚本中:
data "azurerm_subscription" "primary" {
}
resource "azurerm_role_definition" "roles" {
count = length(var.roles)
name = "${var.role_prefix}${var.roles[count.index]["suffix_name"]}${var.role_suffix}"
scope = "${data.azurerm_subscription.primary.id}"
permissions {
actions = split(",", var.roles[count.index]["actions"])
not_actions = split(",", var.roles[count.index]["not_actions"])
}
assignable_scopes = ["${data.azurerm_subscription.primary.id}"]
}
有没有办法设置deployment_mode
?
您误解了 terraform 的工作原理。它只会在无法编辑资源时销毁资源。如果编辑可行(至少 Terraform 应该认为它可行),Terraform 将只更新服务,但在您创建资源后许多东西是不可变的(名称是一个很好的例子)。简而言之:如果您尝试更改不可变 属性(或者更准确地说 - 属性 terraform 认为它是不可变的)terraform 将 destroy\create 资源,否则它将更新它。
此外,您误解了 complete\incremental 部署模式 ;)