Does pulumi handle resource name restriction? - au...
# general
g
Does pulumi handle resource name restriction? • automatically • is this based on the provider • do I need to write my own code?
Copy code
aws:lb/targetGroup:TargetGroup resource 'abc-app-backend-staging-fg-alb-tg' has a problem: "name" cannot be longer than 32 characters. Examine values at 'TargetGroup.Name'.
b
that looks like it's coming from the AWS API, rather than the provider itself, but can't be totally sure
g
Yes, it does, I found out that someone else had this issue with the TargetGroup. I remember that CDK did some sort of hashing on resource names to ensure uniqueness and comply with the naming restriction. I noticed that pulumi also adds some unique string at the end of the resource names. However, unique string is not added if
name
argument is supplied to the resource. My TargetGroup got suffix like
-80f0cdf
- how does pulumi compute this value? I was thinking that I can write a function that would mimic the behaviour.
Is the length of the "random" suffix
-80f0cdf
always the same?
b
@great-sunset-355 you can turn that autonaming off by supplying a name arguement to the resource args
g
@broad-dog-22463 Thanks, I do not want to turn it off. - that would result in conflicts. I'm curious how the name is produced. I'm thinking of similar approach that CDK has. To prevent conflicts: 1) check the naming limits (I can supply this as parameter) 2) Calculate a hash from
name
parameter that fits the service limits
or is this something I'd use transform for?