https://pulumi.com logo
#general
Title
# general
b

brainy-lion-38675

09/13/2021, 6:21 PM
pulumi providers that are based on terraform - is there a way to have them auto generate resource names?
b

billowy-army-68599

09/13/2021, 6:24 PM
it should do that as part of the bridge, is there something not working?
b

brainy-lion-38675

09/13/2021, 6:27 PM
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

billowy-army-68599

09/13/2021, 6:41 PM
can you share your code?
b

brainy-lion-38675

09/13/2021, 6:41 PM
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

billowy-army-68599

09/13/2021, 6:43 PM
glad you're having success!
b

brainy-lion-38675

09/13/2021, 6:46 PM
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

billowy-army-68599

09/13/2021, 6:48 PM
if you specify the name of the machine, it won't autoname, if you remove that it should work
b

brainy-lion-38675

09/13/2021, 6:48 PM
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

billowy-army-68599

09/13/2021, 7:02 PM
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

brainy-lion-38675

09/13/2021, 7:02 PM
ok, so I do have to ensure that the resource name is unique?
b

billowy-army-68599

09/13/2021, 7:03 PM
that's right
b

brainy-lion-38675

09/13/2021, 7:03 PM
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

billowy-army-68599

09/13/2021, 7:04 PM
the resource names shouldn't change on each run, it's a declarative state
what would you need to automate?
b

brainy-lion-38675

09/13/2021, 7:05 PM
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

billowy-army-68599

09/13/2021, 7:06 PM
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

brainy-lion-38675

09/13/2021, 7:07 PM
ok
I will revisit this tomorrow with a fresh pair of eyes
thanks for your help, much appreciated