https://serverless-stack.com/ logo
#sst
Title
# sst
b

Blake E

08/31/2021, 5:40 PM
So.. I’ve long battled with “custom named” resources with cloudformation, and getting errors like:
Copy code
CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename dev-my-stack-myTableName and update the stack again.
I believe.. cloudformation natively can create dynamic names, or maybe it was CDK POCs I did in the past - can’t seem to remember.
sst
have support for this?
I am still of two minds around whether I like the friction or not, but generally - I don’t lol. I’d prefer cdk/sst/cloudform to pick a name with a custom prefix, like
dev-my-stack-myTableNameRANDOMISH
I’m more than happy to always refer to these names dynamically (via exports, ssm etc) so I don’t really care what the name is, just that it’s logically sorted and such in console
t

thdxr

08/31/2021, 5:42 PM
Does
this.getLogicalId()
help?
Or
app.logicalPrefixedName
b

Blake E

08/31/2021, 5:43 PM
I had looked into that before, but did not work for me - didn’t seem to have any effect but I imagine I was missing something in interface it provides.
currently my resource names are built on via the default
stage-stackName-constructId
s

Sam Hulick

08/31/2021, 6:54 PM
I do the same thing. I prefix with
${stack.stackName}-
. and I ran into this same error not too long ago.. so I just commented out the DB cluster name, and then it worked fine
b

Blake E

08/31/2021, 6:59 PM
yeah, I had already done that - but dynamodb is giving the albeit very pretty name. I’ll dig into https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tablename and https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html to see what cfn is doing natively appreciate the thoughts tho @Sam Hulick 😄
UPDATE - For dynamodb tables (maybe for other resources as well), simply excluding the
dynamodbTable.tableName
properly defaulted to the pretty (and static) table name of:
stage-my-stack-constructId
but by passing explicitly
undefined
as tableName I get my desired outcome of table like:
dev-my-stack-myConstructId6036D346-144DSHF08MUGS
🏆
(I’m working with projection tables which can be re-hydrated on-demand from our eventStore - so really like keeping these tables flexible and replaceable)
t

thdxr

08/31/2021, 7:24 PM
ah weird