vmware-archive / legacy-terraform-provider-vra7

Terraform provider for vRealize Automation 7
Mozilla Public License 2.0
60 stars 35 forks source link

Terraform destroy doesn't work #93

Open VincenzoDo opened 6 years ago

VincenzoDo commented 6 years ago

Hello,

as the title states I'm not able to destroy a VM using the plugin. No log output is written to vra-terraform.log during the destroy operation, so I enabled terraform debug logging which is attached here. tflog.txt

TF file:

provider "vra7" {
  username = "${var.vra_username}"
  password = "${var.vra_password}"
  tenant   = "${var.vra_tenant}"
  host     = "${var.vra_host}"
  insecure = "true"

}

resource "vra7_resource" "example_machine1" {
   catalog_name = "base"
   businessgroup_id = "dfaa1892-f422-425f-99c6-12345678"

   resource_configuration = {
        base.cpu = "2"
    base.memory = "2048"
        base.Linux.Hostname = "myvm"
        base.Linux.RootPassword = "mypassword"
        base.VirtualMachine.Network0.Name = "mynetwork"
     }

}

Expected Behavior

The VM gets destoryed

Actual Behavior

No action is performed on the VM and the state is cleared of any info about it so no other commands can be executed.

Specifications

Prativa20 commented 6 years ago

@VincenzoDo Can you please check and confirm that this is not the case as mentioned in the log?

VincenzoDo commented 6 years ago

Sure, I can confirm the VM exists and was not deleted previously.

Prativa20 commented 6 years ago

@VincenzoDo Can you also verify if Destroy Deployment action is enabled for in entitlement? I could reproduce this when my Destroy Deployment action is not added in entitlement.

VincenzoDo commented 6 years ago

@Prativa20 The destroy deployment action is enabled, I can destroy the deployment from the UI.

Prativa20 commented 6 years ago

@VincenzoDo I could not reproduce it and the console logs here are also not very useful. I will create a PR with some more debug logs. And you can with the latest code.

VincenzoDo commented 6 years ago

@Prativa20 Ok, I will wait for the PR

Prativa20 commented 6 years ago

@VincenzoDo Can you try with the latest code? I have added debug logs as part of #100 Please attach the vra-terraform.log file. Thanks!

VincenzoDo commented 6 years ago

@Prativa20 destroy action still fails, here you can find the log for the destroy part: tflog_destroy.txt

Prativa20 commented 6 years ago

@VincenzoDo The log says that the destroy action template required for deleting the resource is not available. And that is the reason destroy is failing. I could reproduce this only when Destroy Machine action is not enabled in the entitlement. But as you mentioned, that it is not the case with your setup. I will open a PR to check in the first place if a destroy is allowed on the resource. If yes, will fetch the template. Will update the issue when the code is merged.

Thanks, Prativa

Prativa20 commented 6 years ago

@VincenzoDo I have created a PR for this which is in review #103

VincenzoDo commented 6 years ago

@Prativa20 I've tested the PR, and get the following when I try to destroy: "* vra7_resource.example_machine1: The deployment base-16198567 cannot be destroyed, your entitlement has no Destroy Deployment action enabled" but as you can see from this screenshot I have the destroy deployment action enabled: image

Prativa20 commented 6 years ago

@VincenzoDo I couldn't reproduce this in my environment. We can have a call to see what is going on.