azure - 使用 terraform 进行增量更新

标签 azure terraform terraform-provider-azure infrastructure-as-code

我正在使用 Terraform 来或阉割我的 Azure 环境。目前我可以执行增量更新。当我运行一个新计划时,它会尝试销毁所有以前应用的资源。例如,我创建了一个新的虚拟机,接下来我运行一个新计划来创建一个角色,它标记了虚拟机以进行销毁。

我知道 Azure ARM 具有增量完整部署模式。

是否可以从 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 将销毁\创建资源,否则它将更新它。

此外,您误解了完整\增量部署模式;)

关于azure - 使用 terraform 进行增量更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59917512/

相关文章:

azure - Web 事件 ADF 中的参数化授权凭据

sql - Azure 数据工厂 V2 : How to pass a file name to stored procedure variable

azure - Microsoft Graph OAuth 问题

terraform - 如何将多个模板文件传递给 terraform 中的 user_Data 变量

azure - 如何将子网 ID 动态添加到 azure keyvault 网络规则

node.js - 在 IISNode 上运行的 Azure Node.js 应用程序中未定义端口

node.js - 尽管指定了 Kubernetes 部署/服务端口,但连接端口错误

amazon-web-services - 将 Kubernetes 应用程序从 AWS 迁移到 GCP

azure - 2种不同的terraform动态声明方式,有什么区别

amazon-web-services - 找不到与 ID 为 vpc 的 vpc 匹配的子网