问题
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
How does this Hash 4FCEEF4A gets generated?
回答1:
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.
来源:https://stackoverflow.com/questions/56729322/hash-in-the-logical-id-of-the-resources-in-cdk-cloudformation