vmware-archive / legacy-terraform-provider-vra7

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

Unable to Destroy items provisioned by an XaaS blueprint #74

Open BenCamareno opened 6 years ago

BenCamareno commented 6 years ago

The Terraform plugin is not able to destroy Items provisioned by an XaaS blueprint:

vra7_resource.control_server: Refreshing state... (ID: 002c1893-2c8a-450d-889c-1079a3f3b820)

An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm.

Enter a value: yes

module.server_1.vra7_resource.server_1: Destroying... (ID: 002c1893-2c8a-450d-889c-1079a3f3b820)

Error: Error applying plan:

1 error(s) occurred:

raghavav commented 6 years ago

Was the resource created using the Terraform plugin?

And what does the .tf file look like?

Thx

BenCamareno commented 6 years ago

@raghavav Yes, the resource was provisioned with the Terraform plugin.

provider "vra7" {

  username = "${var.username}"
  password = "${var.password}"
  tenant   = "${var.tenant}"
  host     = "${var.host}"
  insecure = false

}

resource "vra7_resource" "server_1" {

  catalog_name = "catalog item"

    catalog_configuration = {

    Deployment           = "server_1"
    OSversion            = "Windows"
    Environment          = "Production"
    Backup               = "true"
    Size                 = "SMALL1_1CPU_4GBRAM_80GBDISK"
    SupportTier          = "Medium Touch"
    Site                 = "Site01"
    DiskSize             = "10"
    NumberOfInstances    = "1"

  }

  deployment_configuration = {

     reasons      = "Deployment"
     description  = "Deployment via terraform"

 }
 resource_configuration {
  ip_address = ""
 }

 count        = "1"
 wait_timeout = "5"

}
raghavav commented 6 years ago

This path is certainly not tested or even supported yet, but it is worth following up on.

Does the XaaS blueprint produce a resource? Can you give some more details of the XaaS blueprint and what it produces?

Thanks

BenCamareno commented 6 years ago

The XaaS Blueprint deploys 1 or more DB servers.

It seems that the resource ID that Terraform retrieves is the Request ID and not the Deployment ID. So when it tries to Destroy there are no items that match that ID.

I was able to successfully Destroy a resource with Terraform if I manually change the resource ID to the Deployment ID in the .tfstate file.

raghavav commented 6 years ago

Yes, the current resource ID is actually a catalog request ID. We need to fix that at some point.

Surely the current code didn't just work for you when you changed the resource ID in the .tfstate file. You must have had to make some changes to the delete code ... did you?

BenCamareno commented 6 years ago

It actually worked just like that, only thing I changed was the ID and away it went. I also had my doubts, but I reproduced it several times.

raghavav commented 6 years ago

Okay, thanks. I have to connect the dots by looking at the code and then get back to you. Something isn't adding up in my head.

BenCamareno commented 6 years ago

@raghavav how's this going? Anything I could help you with?

carlosaya commented 5 years ago

any updates on this issue?

apipawho commented 5 years ago

How are you getting the proper names for the values needed in the XaaS blueprint for catalog configuration ? I have several XaaS blueprints, and in them are validations (i.e. external API/DB lookups).