I'm trying to strip off the random characters from a set of Logical IDs in AWS CDK. (Won't go into too much detail about why as it isn't relevant to the question but the basic reason is so some resources can be retained after stack deletion and then left as-is when recreating the stack. Would like to write a function that will do this automatically for all nodes in a tree).
Have noticed that CDK adds its own random characters onto the end of Logical IDs. E.g:
As can be seen above, some of these have 8 random characters and others have 11. (There might be other lengths too but haven't come across any yet). The question I'd like an answer for is how to reliably determine the number of random characters used in any Logical ID?
CDK Logical IDs are suffixed by 8 characters taken from the md5 hash of the construct tree path.
The OP's examples all conform to the 8-character pattern. The "extra" characters you see are part of the resource name: IGW = Internet Gateway and EIP = Elastic IP.