Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow VM folder to pre-exist #44

Open
jesusmah opened this issue Jan 18, 2019 · 5 comments
Open

Allow VM folder to pre-exist #44

jesusmah opened this issue Jan 18, 2019 · 5 comments
Assignees

Comments

@jesusmah
Copy link

Per Peter Van Sickel,

At the moment, terraform for VMware will error out if the folder where VM will be place under already exists.

This enhancement should handle this situation.

@jesusmah jesusmah self-assigned this Jan 18, 2019
@jesusmah
Copy link
Author

@petervansickel, what is the use case for this?

Apparently, there is no easy way to implement an if-then-else statement in terraform to handle the situation where the folder your VMs will go into already exists prior to your first terraform apply.

We can either create a folder (for which we must ensure that folder does not exist) or import a folder (for which we must ensure the folder already exist) before you execute terraform apply...

In fact, it might be a better practice to error out when a folder already exists so that you avoid team mates (or even worse, people you that does not have anything to do with you project wise) deploying stuff into your folder in case permissions in the vCenter are a bit too loose...

What are your thoughts around this?
@hassenius

@hassenius
Copy link

Seems like this is a design decision by the vsphere guys: hashicorp/terraform-provider-vsphere#219

@petervansickel
Copy link

The use case arose out of the folder structure we're using in the CSP lab.
When you end up rerunning the terraform multiple times due to something having screwed up (a bunch of cockpit errors, in my case), it is annoying to have to delete the folder. There seem to be scenarios where I would do a plan-apply cycle and I ended up having to delete the folder to get things into a state where that wasn't a cause for erroring out.

@hassenius
Copy link

I think that's probably a perfect use case for importing the folder:
Importing
An existing folder can be imported into this resource via its full path, via the following command:

terraform import vsphere_folder.icpenv /default-dc/vm/terraform-test-folder

In this case the folder would of course be deleted again with a terraform destroy since terraform takes over the lifecycle of imported resrouces

@rootmadhu
Copy link

the command didn't work for me. with terrform 0.13.6. I don't understand. I destroyed the cluster and the folder was deleted and again removed the tfstate file and hidden terraform folders.

Now I init +plan & apply the folder creates in this apply portion but fails indicating folder exists ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants