散列在CDK / Cloudformation中资源的逻辑ID中 [英] Hash in the Logical Id of the resources in CDK/Cloudformation
问题描述
每当我从CDK生成cloudformation模板时,就会发现在逻辑ID中会添加某种哈希。哈希表示什么意思?例如。
Whenever I generate cloudformation template from CDK, I see that in logical ids, it adds some kind of Hash. What does that Hash mean? Eg.
Test4FCEEF4A
Test4FCEEF4A
此哈希4FCEEF4A是如何生成的?
How does this Hash 4FCEEF4A gets generated?
推荐答案
使用 allocateLogicalId
方法设置资源的逻辑ID,您可以在其中找到此处。它调用 makeUniqueId
方法,您可以找到此处。在 makeUniqueId
方法中,它创建逻辑ID的 hash
组件和 human
可读的逻辑ID组件。它使用 crypto
库使用 path
创建md5哈希,该哈希是从 crypt c节点的ID中获得的。 CfnElement并返回一个十六进制值。因此,您看到的哈希4FCEEF4A是在
makeUniqueId
方法中创建的哈希
组件。
The logical IDs for resources are set using the allocateLogicalId
method which you can find here. It calls the makeUniqueId
method which you can find here. In the makeUniqueId
method, it creates a hash
component of the logical ID and a human
-readable component of the logical ID. It uses the crypto
library to create an md5 hash using path
, which it gets from the IDs of the nodes of the CfnElement and returns a hex value. So the Hash 4FCEEF4A you see is the hash
component that is created in the makeUniqueId
method.
这篇关于散列在CDK / Cloudformation中资源的逻辑ID中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!