diff --git a/packages/aws-cdk-lib/core/lib/annotations.ts b/packages/aws-cdk-lib/core/lib/annotations.ts index 19e83f0ec43af..2d5d75dab3ef0 100644 --- a/packages/aws-cdk-lib/core/lib/annotations.ts +++ b/packages/aws-cdk-lib/core/lib/annotations.ts @@ -143,7 +143,8 @@ export class Annotations { private addMessage(level: string, message: string) { const isNew = !this.scope.node.metadata.find((x) => x.data === message); if (isNew) { - this.scope.node.addMetadata(level, message, { stackTrace: this.stackTraces }); + let normalizedMessage = typeof message === 'string' ? message : JSON.stringify(message); + this.scope.node.addMetadata(level, normalizedMessage, { stackTrace: this.stackTraces }); } } } @@ -259,4 +260,4 @@ function removeWarning(construct: IConstruct, id: string) { function ackTag(id: string) { return `[ack: ${id}]`; -} \ No newline at end of file +}