https://serverless-stack.com/ logo
#help
Title
# help
p

Patrick

02/14/2022, 10:32 PM
Hey everyone! Is there an easy way to simplify how resources are named when they’re deployed with SST? For example I have a IAM User Group with the generated name:
dev-appname-MyStack-Admins8B360DEA-U132VR1JXSY0
. I would love to be able to set the name myself so I could name it something like:
dev-appname-MyStack-Admins
t

thdxr

02/14/2022, 10:39 PM
Curious what you're looking to solve with cleaner names
Is it to cleanup how things look in the AWS console?
p

Patrick

02/14/2022, 10:49 PM
Cleanup how things look in the console, but also it’s just more practical for some things to have shorter names
For example, when programmatically creating users, the usernames are long strings similar to the one I shared for the User Group. It’s impractical to have such long usernames, especially when those usernames will be given to non-technical contributors that need console access to manage certain things like billing, logs, metrics, etc
t

thdxr

02/14/2022, 10:57 PM
Yeah agreed it's a pain point and I hate how messy it is. Most constructs do accept a
name
prop to let you set it explicitly
p

Patrick

02/14/2022, 11:00 PM
Pretty new to the CDK and didn’t realized this. Thanks for the help!
d

Derek Kershner

02/14/2022, 11:03 PM
SST also provides a
logicalName
helper on
<http://sst.App|sst.App>
, you wrap your desired name in it.
p

Patrick

02/14/2022, 11:13 PM
I tried using the
app.logicalPrefixedName
util but it made my names even worse. I went from:
Copy code
dev-appname-MyStack-Admins8B360DEA-U132VR1JXSY0
To this:
Copy code
dev-appname-MyStack-devappnameMyStack32VR1JXSY0
Manually overwriting the names in the constructor props like @thdxr mentioned allowed me to get the names like I wanted
d

Derek Kershner

02/15/2022, 3:45 AM
if you overwrite with the logicalPrefixedName surrounding only the last part, then you can have accurate app and stack names without having to manually update
basically, combine our advice for best of all worlds