How do you generate dynamic names for each resourc...
# general
r
How do you generate dynamic names for each resource based on a similar pattern as this: <resource type>-<product>-<environment>-<region> like: func-todosaas-dev-ne
e
Oh we're actually looking this week at seeing if we can add static members to every resource type with a string of the resources type-token, so that would help with this. But in general just use your languages standard string formatting tools to do this, all these things should be statically known.
r
@echoing-dinner-19531 I have done the following but it is repeated code because each resource should have different name prefix and some resources have special constraints such as length and format and casing, are you working on a solution for this?
Copy code
"apim" + "-" + projectName + stackName + "-" + regionShortCode
e
We have https://github.com/pulumi/pulumi/issues/1518 but it turns out to be really hard problem to solve in general. It's not easy to move name logic to the engine because individual resources can have strange and hard to express restrictions, it's not easy to put name logic in providers because there are a lot of them and keeping all of them updated with some central name logic is hard, and not even possible given some are in different langauges. This is much easier to express in user programs where you could just have a
makeName(resource, resname)
function
r
@echoing-dinner-19531 Yeah I did use such a MakeName function but the issue is that it doesnt scale when you need to implement for plus 200 resource types, it is isnt automatic, but it does cut down on the name generation code. Let me know if you figure out a solution.
e
Watch that issue, if we work anything big out we'll put it there
r
@echoing-dinner-19531 Thanks I will do that