Creating new resource in Terraform using vCloud Director provider

813 views Asked by At

I created a pair vm+vapp using the following Terraform code:

resource "vcd_vapp" demo_vapp {
  name = "demo"
  power_on = true
}

resource "vcd_vapp_vm" demo {
  vapp_name     = "${vcd_vapp.demo_vapp.name}"
  name          = "demo"
  catalog_name  = "${var.template_catalog}"
  template_name = "${var.clone_source}"
  memory        = "${var.mem_size}"
  cpus          = "${var.cpu_count}"
  network {
    type               = "org"
    name               = "${var.network_name}"
    ip                 = ""
    ip_allocation_mode = "POOL"
    is_primary         = true
  }
  depends_on = ["vcd_vapp.demo_vapp"]
}

In vcloud panel from the vApp menu level, I created a template and put in custom catalog. Then I wanted to make more clones using this very template as a source. Unfortunately I ended up with:

vcd_vapp.demo_vapp: Creating..
vcd_vapp.demo_vapp: Creation complete after 5s [id=demo]
vcd_vapp_vm.demo: Creating...
Error: merror adding VM: &errors.errorString{s:"vApp Template shape is not ok (status: 3)"}

  on 02_template.tf line 19, in resource "vcd_vapp_vm" "demo":
  19: resource "vcd_vapp_vm" demo 

From what I found here and here code 3 is an error returned when object is suspended and indeed, the template (as others) is in suspended state. Which is nonsense, what other state should be the template in? Not in 'running' I recon - it's just a template! Does anybody have an idea how to do such an operation? TF is 0.12.8 vcd plugin 2.4

1

There are 1 answers

0
Guillermo Ettlin On

I got the same error. The issue is that the template was created from a powered-on VM.

My solution was to re-create the template using a powered-off VM.