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

few-carpenter-12885

02/27/2023, 8:52 PM
I'm wanting to generate a docker container style name like "sad_panda" or "amazing_aardvark", use that to name a resource, and store it in state. I've used
@pulumi/random
to generate things and store them in state. However, I don't see any sort of generic construct to do this. Does this need to be a custom provider?
l

little-cartoon-10569

02/27/2023, 8:57 PM
For which resources? Most resources have a
name
parameter that does what you want.
f

few-carpenter-12885

02/27/2023, 8:58 PM
My experience in the past is that if I were to pull in some other name generator, it would attempt to generate a random value for the
name
and attempt a rename of the resource.
Essentially, I'm looking for something to run the name generation the first time, then just retrieve from state all subsequent calls, similar to the pulumi random
Hopefully, I'm not thinking about this incorrectly
b

billowy-army-68599

02/27/2023, 9:20 PM
@few-carpenter-12885 this is what
RandomPet
does: https://www.pulumi.com/registry/packages/random/api-docs/randompet/
f

few-carpenter-12885

02/27/2023, 9:22 PM
Ah, I did see that package, makes sense. What is the preferred way to duplicate then modify this functionality? Create a class that
extends pulumi.CustomResource
?
e

echoing-dinner-19531

02/27/2023, 10:21 PM
Are you trying to set the resource name via this? That's not really supported right now, the name is what tells us what to look up in state, you can't build the name based on something in state because until you have the name you can't look up anything in state...