diff --git a/packages/@aws-cdk/core/lib/private/intrinsic.ts b/packages/@aws-cdk/core/lib/private/intrinsic.ts index f880162fa9015..88cbe6ee02af7 100644 --- a/packages/@aws-cdk/core/lib/private/intrinsic.ts +++ b/packages/@aws-cdk/core/lib/private/intrinsic.ts @@ -2,6 +2,20 @@ import { IResolvable, IResolveContext } from '../resolvable'; import { captureStackTrace } from '../stack-trace'; import { Token } from '../token'; +/** + * Customization properties for an Intrinsic token + * + * @experimental + */ +export interface IntrinsicProps { + /** + * Capture the stack trace of where this token is created + * + * @default true + */ + readonly stackTrace?: boolean; +} + /** * Token subclass that represents values intrinsic to the target document language * @@ -20,12 +34,12 @@ export class Intrinsic implements IResolvable { private readonly value: any; - constructor(value: any) { + constructor(value: any, options: IntrinsicProps = {}) { if (isFunction(value)) { throw new Error(`Argument to Intrinsic must be a plain value object, got ${value}`); } - this.creationStack = captureStackTrace(); + this.creationStack = options.stackTrace ?? true ? captureStackTrace() : []; this.value = value; } diff --git a/packages/@aws-cdk/core/lib/util.ts b/packages/@aws-cdk/core/lib/util.ts index 7416189a33360..6924b197667af 100644 --- a/packages/@aws-cdk/core/lib/util.ts +++ b/packages/@aws-cdk/core/lib/util.ts @@ -80,7 +80,7 @@ export function filterUndefined(obj: any): any { */ export class PostResolveToken extends Intrinsic implements IPostProcessor { constructor(value: any, private readonly processor: (x: any) => any) { - super(value); + super(value, { stackTrace: false }); } public resolve(context: IResolveContext) {