So I've created a `const f = new vsphere.Folder(.....
# general
s
So I've created a
const f = new vsphere.Folder(....)
and now I'm trying to use it with `vsphere.getVirtualMachine({ name:
${f.path}/vm-name
})` but I'm getting
error fetching virtual machine: vm 'Calling [toString] on an [Output<T>] is not supported.
Anyone know how to get the path as a string?
f
Usually, you would use
apply
with an
Output
(see https://www.pulumi.com/docs/intro/concepts/programming-model/) — but I want to better understand what you’re doing, too. I’m not really familiar with vSphere, but I thought
Folders
are an organizational concept for things, which might include VMs. In which case, if you are attempting to
get
a VM with a certain path, doesn’t that imply the
Folder
already exists? If the
Folder
already exists, you wouldn’t
new
it unless you’re also including
import
so that it’s managed the pulumi stack.
s
I just got started with Pulumi on Friday so I'm still learning how to use it really. But in this instance, if I deploy a new stack, I want it to create a folder or get it if already exists.
I'm hoping I can then call Packer somehow to stand up a new template and then use that template with some new VirtualMachine calls. The getVirtualMachine call for the template is where I'm trying to use the folder path and appending the template name.
getVirtualMachine requires a full path, I can't specify name and then folder, i have to pass
${folder}/${template-name}
effectively
f
I think I’m confused how the template
${f.path}/${template-name}
already exists if you’ve just created the folder? If that template already exists, it implies you already know the name of the folder, in which case you shouldn’t need to rely on the output value?
s
I was hoping to figure out a way to create the template in my pulumi code.
But also yea, I am creating the path dynamically in my code. So I do "know" it already and I can just use the same var I used to create the folder in the getVirtualMachine call. For some reason I thought it'd be better to actually use the path from the actual folder object. But if it doesn't really matter
f
Yeah, if you know the value, you should just use it there. Typically, you’d want to use the
Output
values when it’s something returned from the API/computed by the provider