Search code examples
azureterraformterraform-provider-azureinfrastructure-as-code

Incremental update with terraform


I'm using Terraform in orcastrating my Azure environment. At the moment I can perform incremental updates. when I run a new plan it tries to destory all previous;y applied resources. Example, I created a new Virtual Machine, next I run a new plan to create a role, it marks the Virtual Machine for destruction.

I know Azure ARM has a deployment mode of incremental or complete.

if it possible to access the deployment_mode property from terraform?

for instance, in this script:

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}"]
}

is there a way to set the deployment_mode?


Solution

  • You are misunderstanding how terraform works. It will only destroy resources if it cannot edit them. If an edit would work (at least terraform should think it will work) terraform will just update the service, but many things are immutable after you've created the resource (name is a reasonably good example). So in short: if you try to change an immutable property (or to be more precise - property that terraform thinks is immutable) terraform will destroy\create resource, otherwise it will update it.

    Also, you are misunderstanding complete\incremental deployment modes ;)