pulumi providers that are based on terraform - is ...
# general
b
pulumi providers that are based on terraform - is there a way to have them auto generate resource names?
b
it should do that as part of the bridge, is there something not working?
b
not sure
im using the vsphere module, which is based on TF
resource_name is not option, so I am just providing “VirtualMachine” as resource name, and I was hoping that it will be prefixed or suffixed with a random id
but instead, if I attempt to create two VM’s, the 2nd will complain about lack of URN uniqueness
b
can you share your code?
b
let me create a simplified example
btw your public repo’s help me a lot to create pulumi provider + build pipeline from a tf module, so thx for that :)
b
glad you're having success!
b
well, its not simplified, sorry about that
line 163 is the one that causes the issues
basically, if I dont ensure that its unique, I will get errors like
Diagnostics:
vsphereindexVirtualMachine (VirtualMachineAAA): error: Duplicate resource URN ‘urnpulumidev:vinci pulumi win desktopvsphereindex/virtualMachineVirtualMachine:VirtualMachineAAA’; try giving it a unique name```
b
if you specify the name of the machine, it won't autoname, if you remove that it should work
b
ah you are right
its the name attribute
that prevens the auto naming, the guide even said so
I missed that, sorry
thx for pointing it out
🙂
well
I dont get it
let’s say I have this
is this supposed to work?
b
no, the names are the same, it should be:
Copy code
import pulumi_random
a = pulumi_random.RandomPassword("password-a", length=8)
b = pulumi_random.RandomPassword("password-b", length=8)
the names need to be unique properties
b
ok, so I do have to ensure that the resource name is unique?
b
that's right
b
I see
so what’s the best way to deal with that if I want to automate that, but also dont want to resource names to change on each run?
b
the resource names shouldn't change on each run, it's a declarative state
what would you need to automate?
b
im trying to create simpler interfaces for the resources I want to use, and ideally, the users of the simplified resources wouldnt have to deal with resource names
b
sorry I'm havinga hard time understanding 😞 If you're creating a component you don't always need to specify the names of each resource, but the component itself still needs a name when it's declared
b
ok
I will revisit this tomorrow with a fresh pair of eyes
thanks for your help, much appreciated