vmware / terraform-provider-vra7

Terraform VMware vRealize Automation 7 provider - VMware has ended the active development of this Terraform Provider, so this repository will no longer be updated.
https://registry.terraform.io/providers/vmware/vra7/latest
Mozilla Public License 2.0
38 stars 33 forks source link

Import a deployment without a request id #57

Closed linkages closed 4 years ago

linkages commented 4 years ago

vRA 7.x version Version: 7.5.0 (Build: 10053500) Terraform version 0.12 terraform-provider-vra7 plugin version 1.0.0

Describe the bug An accident was made in vRA and everyone's deployments were removed from their business groups. This was fixed by re-registering all deployments back with the appropriate business groups but there is a side effect of losing all the requests. Because of this, anyone that used terraform in the past to deploy catalog items, can no longer use terraform to maintain them since the request ids are gone.

I was wondering if there is a way to import a vra7_deployment by using the deployment id instead of the request id.

Prativa20 commented 4 years ago

@linkages I thought about it and the reason I did not replace the id in the state file from request to deployment id is because it will break the existing deployment resources managed by the provider.

I have introduced a data source for vra7_deployment resource. It accepts deployment id. The request id can be fetched from the state file after you get the deployment from the data source. Then use the request id to import and manage your deployment. Here is the documentation and example. https://github.com/terraform-providers/terraform-provider-vra7/blob/master/website/docs/d/vra7_deployment.html.markdown

Let me know if this works for you.

Thanks, Prativa

mcascone commented 4 years ago

I thought the point of import was to bring in a machine(s) that had not been created by Terraform, so it could be managed by TF. Do i read this right, that you can only import entities that have previously been created by Terraform?

Prativa20 commented 4 years ago

@mcascone Yes, you can import the deployment even if has not been created by Terraform. To import any deployment, you need the catalog item request id. But @linkages has mentioned that they do not have the request id but only have the deployment id. In such a case, the request id can be fetched through a vra7_deployment data source. Once the data source is created, go to the state file and fetch the request id. This request id can then be used to import the deployment. Here is the documentation and example. https://github.com/terraform-providers/terraform-provider-vra7/blob/master/website/docs/d/vra7_deployment.html.markdown

Thanks, Prativa

Prativa20 commented 4 years ago

Hi @mcascone

Closing this issue as you can import any deployment irrespective of how it is created (through the terraform provider or vRA UI or API). The request id is required to do that.