Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vapp_template_id missing after import vcd_vapp_vm, triggers recreate of the vcd_vapp_vm #1170

Closed
cjswart opened this issue Nov 28, 2023 · 1 comment
Assignees

Comments

@cjswart
Copy link

cjswart commented Nov 28, 2023

Hello,

After changing from catalog_name/template_name to vapp_catalog_id in the vcd_vapp_vm resource the vm is destroyed and recreated
I removed the resource from the state file and import the resource back in the state file
After the import the vapp_template_id is not added to the state file still forcing a recreate of the vcd_vapp_vm resource

Terraform Version

Terraform v1.6.4
on windows_amd64

  • provider registry.terraform.io/hashicorp/template v2.2.0
  • provider registry.terraform.io/vmware/vcd v3.10.0

Affected Resource(s)

Please list the resources as a list, for example:

  • vcd_vapp_vm

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

data "vcd_catalog" "my-catalog" {
  name = var.vapp_vm_template.catalog_name
  org  = var.vapp_vm_template.org
}
data "vcd_catalog_vapp_template" "osboot" {
  catalog_id = data.vcd_catalog.my-catalog.id
  name       = var.vapp_vm_template.template_name
  org  = var.vapp_vm_template.org
}

resource "vcd_vapp_vm" "vm" {
  org                    = var.org
  vdc                    = lookup(var.vapp_vm_settings, "vdc", var.vdc)
  vapp_name              = var.vapp_vm_settings.vapp_name
  name                   = var.vapp_vm_settings.hostname
  vapp_template_id       = try(var.vapp_vm_settings.vapp_template_id, data.vcd_catalog_vapp_template.osboot.id)
  memory                 = try(var.vapp_vm_settings.memory, null)
  cpus                   = try(var.vapp_vm_settings.cpus, null)
  cpu_cores              = try(var.vapp_vm_settings.cpu_cores, null)
  os_type                = try(var.vapp_vm_settings.os_type, null)
  hardware_version       = try(var.vapp_vm_settings.hardware_version, null)
  computer_name          = try(var.vapp_vm_settings.hostname, null)
  cpu_hot_add_enabled    = try(var.vapp_vm_settings.cpu_hot_add_enabled, true)
  memory_hot_add_enabled = try(var.vapp_vm_settings.memory_hot_add_enabled, true)
  storage_profile        = try(var.vapp_vm_settings.storage_profile, null)

  customization {
    admin_password                      = try(var.vapp_vm_settings.customization.admin_password, null)
    allow_local_admin_password          = try(var.vapp_vm_settings.customization.allow_local_admin_password, null)
    auto_generate_password              = try(var.vapp_vm_settings.customization.auto_generate_password, null)
    change_sid                          = try(var.vapp_vm_settings.customization.change_sid, null)
    enabled                             = try(var.vapp_vm_settings.customization.enabled, null)
    force                               = try(var.vapp_vm_settings.customization.force, null)
    join_domain                         = try(var.vapp_vm_settings.customization.join_domain, null)
    join_org_domain                     = try(var.vapp_vm_settings.customization.join_org_domain, null)
    must_change_password_on_first_login = try(var.vapp_vm_settings.customization.must_change_password_on_first_login, null)
    number_of_auto_logons               = try(var.vapp_vm_settings.customization.number_of_auto_logons, null)
  }
}

Expected Behavior

vapp_template_id present in the state file after importing the vcd_vapp_vm resource

Actual Behavior

vapp_template_id is missing forcing a recreate of the vcd_vapp_vm

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform state rm vcd_vapp_vm.vm
  2. terraform import vcd_vapp_vm.vm
  3. terraform state show vcd_vapp_vm.vm

User Access rights

Information about user used. Role and/or more exact rights if it is customized.

Important Factoids

Is there anything atypical about your accounts that we should know?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

  • Issue #0000
dataclouder pushed a commit to dataclouder/terraform-provider-vcd that referenced this issue Jun 3, 2024
Signed-off-by: Giuseppe Maxia <[email protected]>
@dataclouder
Copy link
Contributor

Hi
Please have a look at the changes made in PR #1274. It would be helpful if you could test your issue by building the terraform-provider-vcd from that branch and seeing if it solves the problem.

dataclouder added a commit that referenced this issue Jun 13, 2024
* Fix Issue #1170
* Add Changelog item

---------

Signed-off-by: Giuseppe Maxia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants