terraform-provider-lxd icon indicating copy to clipboard operation
terraform-provider-lxd copied to clipboard

Explicitly defining `remote` on Instance triggers re-creation (even if it matches the default)

Open danielcotton opened this issue 7 months ago • 1 comments

Example:

provider "lxd" {
  remote {
    name = "lxd1"
    default = true
  }
}

resource "lxd_instance" "instance1" {
  name = "instance1"
  image = "ubuntu:22.04"
}

Steps to reproduce:

  1. Change definition of lxd_instance.instance1 to explicitly define remote = "lxd1"
  2. Run terraform apply

Expected result: Apply should be a no-op, because we are asking for the instance to be deployed where it already is

Actual result: Terraform plans to recreate the instance

Additional info: The remote attribute currently has RequiresReplace(), but this should probably be more specific. target, for example, is RequiresReplaceIfConfigured() (which would fix the issue). However, does that mean a change wouldn't be triggered if e.g. the value was changed from not-configured (i.e. the default) to a non-default configured value?

danielcotton avatar Jul 22 '24 05:07 danielcotton