I’m using AWS CDK to create Infrastructure and Code but when I deployed my stacks the resource names were too long. For example, when one stack was deployed the name was something like this:
subnet-01b6cba6915f51b9d / NetworkStack/vpc/devvpc/compute-subnet-priv-a-devSubnet1
I’d like to have the last part of the name, because is very difficult to read and is horrible. That happens with the logical names too.
Does someone know how to prevent or fix this? Thanks.
Psdt: I’m using TS
A solution in the config files or a level code using AWS CDK
2
Answers
Indeed, those names that can be obtained through the CDK can be somewhat complicated, I will tell you something that you could validate, I don’t know if you have already done it but these names can be customized.
Let’s remember that CloudFormation is present in the background, what the documentation says and I saw in some cases is that a physical name can be indicated for when these resources are created, in the case of Python it could look something like this.
On my side I don’t always do it, but of course if we want an implementation aligned with specific standards and nomenclatures it will be necessary, I saw this question in AWS re:Post I share the reference so you can take a look too.
That said, if you ask me why those random names, it is ultimately what CloudFormation does when it is not told exactly, this is backed up with the corresponding documentation, regards.
The name is comprised of the logical ID and a hash generated by CloudFormation. The logical ID is calculated by concatenating the construct IDs in the path (all the construct IDs starting from the top Stack down to the resource).
You can provide your own physical name, but this is discouraged. From the best practices doc: