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

great-sunset-355

12/23/2021, 10:23 AM
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

billowy-army-68599

12/23/2021, 10:32 AM
that looks like it's coming from the AWS API, rather than the provider itself, but can't be totally sure
g

great-sunset-355

12/23/2021, 10:39 AM
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

broad-dog-22463

12/23/2021, 11:23 AM
@great-sunset-355 you can turn that autonaming off by supplying a name arguement to the resource args
g

great-sunset-355

12/23/2021, 3:34 PM
@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?
9 Views