如何确定随机字符的数量CDK添加到逻辑ID中?
我正在尝试从 AWS CDK 中的一组逻辑 ID 中删除随机字符。 (不会详细说明原因,因为它与问题无关,但基本原因是在堆栈删除后可以保留一些资源,然后在重新创建堆栈时保持原样。想写一个函数将为树中的所有节点自动执行此操作)。
注意到 CDK 将自己的随机字符添加到逻辑 ID 的末尾。例如:
- exampleservicevpc0CD2D33A
- exampleservicevpcingresssubnetEIPFE5428D1
- exampleservicerole41CC6F17
- exampleserviceanothervpcIGW1CABF45D
从上面可以看出,其中一些有 8 个随机字符和其他有 11。(可能还有其他长度,但还没有遇到过 然而)。我想要答案的问题是如何可靠地确定任何逻辑 ID 中使用的随机字符数?
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:
- exampleservicevpc0CD2D33A
- exampleservicevpcingresssubnetEIPFE5428D1
- exampleservicerole41CC6F17
- exampleserviceanothervpcIGW1CABF45D
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CDK 逻辑 ID 的后缀为 8 个字符,取自 构造树路径的 md5 哈希。
OP的例子都符合8字符模式。您看到的“额外”字符是资源名称的一部分:
IGW
= Internet 网关和EIP
= 弹性 IP。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 andEIP
= Elastic IP.