https://serverless-stack.com/ logo
#random
Title
# random
t

thdxr

08/27/2021, 2:22 PM
I've asked this before but I cannot figure out the naming conventions with cdk. Here are some scenarios. If I name my stack
MyStack
it gets deployed as dev-app-MyStack which maybe suggests I should name it
my-stack
But then if I use hyphenated case for my constructs eg
my-func
the hyphens get removed in some cases because some constructs don't allow hyphens in the name This is a small minor thing but I can't help but be annoyed by it. What is everyone else doing?
a

Adrián Mouly

08/27/2021, 2:23 PM
I hate current naming convention.
The functions and roles and such seems to follow other naming convention.
s

Sam Hulick

08/27/2021, 3:27 PM
the PascalCase names are just internal in the SST code, for me.
MyStack
. but in AWS, it’s
dev-my-stack-*
and my Lambda functions are named like
dev-my-stack-someFuncName
a

Adrián Mouly

08/27/2021, 4:12 PM
You put the name of the stack in the function too?
s

Sam Hulick

08/27/2021, 4:12 PM
yep, because I have 4 stacks. so it helps me sort through my massive list of functions and find stuff
a

Adrián Mouly

08/27/2021, 4:12 PM
Yeah I have bunch of stack too.
I don’t put the stack name but a name that works with the stack.
I have…
TasksApiStack
, and my function has
dev-tasks-findAll
.
But maybe is better to name my func with the stack name.
s

Sam Hulick

08/27/2021, 4:14 PM
whatever works for you! 🙂 but I do like talking to other devs about naming conventions & other best practices. sometimes I’ll pick up a new way of doing something that makes me more efficient
a

Adrián Mouly

08/27/2021, 4:15 PM
Yeah my worry is the char limit on lambda func name.
Because I also have the name of my company on the name.
Still trying to find the correct name convention.
j

Jad

08/27/2021, 8:34 PM
Also always seem to be going down rabbit holes with naming conventions. Where possible I prefer to avoid the CDK default and have currently settled on
project-stage-NameOfResourceHere
. Project could also be synonymous with a stack or logical grouping of stacks. On this note, what are you guys doing with REST API’s (ApiGatewayV1Api in particular)? It looks like SST is enforcing the restApiName to
root.logicalPrefixedName(id)
, but am not sure if I am missing something?