Hey everyone! Is there an easy way to simplify how...
# help
p
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
Curious what you're looking to solve with cleaner names
Is it to cleanup how things look in the AWS console?
p
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
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
Pretty new to the CDK and didn’t realized this. Thanks for the help!
d
SST also provides a
logicalName
helper on
<http://sst.App|sst.App>
, you wrap your desired name in it.
p
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
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