Skip to content

Commit 5844389

Browse files
committed
unresolve tokens for annotations
1 parent 7538a84 commit 5844389

File tree

1 file changed

+17
-1
lines changed
  • packages/aws-cdk-lib/core/lib/stack-synthesizers

1 file changed

+17
-1
lines changed

packages/aws-cdk-lib/core/lib/stack-synthesizers/_shared.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,23 @@ function collectStackMetadata(stack: Stack) {
100100

101101
if (node.node.metadata.length > 0) {
102102
// Make the path absolute
103-
output[Node.PATH_SEP + node.node.path] = node.node.metadata.map(md => stack.resolve(md) as cxschema.MetadataEntry);
103+
output[Node.PATH_SEP + node.node.path] = node.node.metadata.map(md => {
104+
// If Annotations include a token, the message is resolved and output as `[object Object]` after synth
105+
// because the message will be object type using 'Fn::Join'.
106+
// It would be easier for users to understand if the message from Annotations were output in token form,
107+
// rather than in `[object Object]` or in object type using 'Fn::Join'.
108+
// Therefore, we don't resolve the message if it's from Annotations.
109+
if ([
110+
cxschema.ArtifactMetadataEntryType.ERROR,
111+
cxschema.ArtifactMetadataEntryType.WARN,
112+
cxschema.ArtifactMetadataEntryType.INFO,
113+
].includes(md.type as cxschema.ArtifactMetadataEntryType)) {
114+
return md;
115+
}
116+
117+
const resolved = stack.resolve(md);
118+
return resolved as cxschema.MetadataEntry;
119+
});
104120
}
105121

106122
for (const child of node.node.children) {

0 commit comments

Comments
 (0)