terraform-provider-vcd
terraform-provider-vcd copied to clipboard
Problem using "vapp_template_id" instead of "catalog_name" and "template_name"
Hello,
I have an Org + catalog in my VCD environment for VM templates that are published to all other orgs. These templates are recreated every month with current patch level, tested and then uploaded to the public catalog. The existing template there will be overwritten. However, this changes the ID of the templates. This results in VMs created from the template being deleted and recreated by Terraform. To work around this, instead of "vapp_template_id" I can use "catalog_name" and "template_name". But these two parameters are marked as deprecated.
Kind regards, Jan
Terraform Version
Terraform v1.4.4 on windows_amd64
- provider registry.terraform.io/vmware/vcd v3.8.2
Affected Resource(s)
Please list the resources as a list, for example:
- vcd_vm
- vcd_vapp_vm
Terraform Configuration Files
data "vcd_org_vdc" "orgvdc" {
name = "orgvdc name"
}
data "vcd_catalog" "templates-catalog" {
name = "templates"
org = "templates"
}
data "vcd_catalog_vapp_template" "ubuntu_template" {
catalog_id = data.vcd_catalog.templates-catalog.id
name = "ubuntu"
}
resource "vcd_vm" "ubuntu01" {
vdc = data.vcd_org_vdc.orgvdc.name
vapp_template_id = data.vcd_catalog_vapp_template.ubuntu_template.id
name = "ubuntu01"
computer_name = "ubuntu01"
memory = 4096
cpus = 2
cpu_cores = 2
storage_profile = "storage profile name"
power_on = true
override_template_disk {
bus_type = "paravirtual"
size_in_mb = 40960
bus_number = 0
unit_number = 0
iops = 0
}
network {
type = "org"
name = vcd_network_routed_v2.ovdc_net_01.name
ip_allocation_mode = "POOL"
is_primary = true
}
customization {
allow_local_admin_password = true
auto_generate_password = false
admin_password = "SomePassword"
}
}
Expected Behavior
A VM once created from a template should not be deleted and recreated because of a change to the template.
Actual Behavior
In the vcd_vm resource, the changed ID causes the VM to be deleted and recreated.
# vcd_vm.ubuntu01 must be replaced
~ vapp_template_id = "urn:vcloud:vapptemplate:5c6fe033-e73e-4094-bfd9-91bd00f9021e" -> "urn:vcloud:vapptemplate:f4f09ddb-0323-4f10-9928-c3ad509655bb" # forces replacement
Steps to Reproduce
- deploy VM from template via Terraform
- overwrite the template in catalog with newer verison
- run terraform apply again
User Access rights
Tested with default Org Admin Role