diff --git a/src/constructs/core/migrating.test.ts b/src/constructs/core/migrating.test.ts index c7b51db049..d4032ad0d0 100644 --- a/src/constructs/core/migrating.test.ts +++ b/src/constructs/core/migrating.test.ts @@ -2,7 +2,7 @@ import "@aws-cdk/assert/jest"; import { SynthUtils } from "@aws-cdk/assert"; import type { BucketProps } from "@aws-cdk/aws-s3"; import { Bucket } from "@aws-cdk/aws-s3"; -import { Logger } from "../../utils/logger"; +import { Annotations } from "@aws-cdk/core"; import type { GuStatefulConstruct } from "../../utils/mixin"; import type { SynthedStack } from "../../utils/test"; import { simpleGuStackForTesting } from "../../utils/test"; @@ -24,8 +24,8 @@ We're calling it here to test the function in isolation. */ describe("GuMigratingResource", () => { - const info = jest.spyOn(Logger, "info"); - const warn = jest.spyOn(Logger, "warn"); + const info = jest.spyOn(Annotations.prototype, "addInfo"); + const warn = jest.spyOn(Annotations.prototype, "addWarning"); afterEach(() => { warn.mockReset(); diff --git a/src/constructs/core/migrating.ts b/src/constructs/core/migrating.ts index 7ad1ffc601..3d57598900 100644 --- a/src/constructs/core/migrating.ts +++ b/src/constructs/core/migrating.ts @@ -1,5 +1,5 @@ import type { CfnElement, IConstruct } from "@aws-cdk/core"; -import { Logger } from "../../utils/logger"; +import { Annotations } from "@aws-cdk/core"; import { isGuStatefulConstruct } from "../../utils/mixin"; export interface GuMigratingStack { @@ -55,19 +55,19 @@ export const GuMigratingResource = { } if (isStateful) { - Logger.warn( + Annotations.of(construct).addWarning( `GuStack has 'migratedFromCloudFormation' set to true. ${id} is a stateful construct and 'existingLogicalId' has not been set. ${id}'s logicalId will be auto-generated and consequently AWS will create a new resource rather than inheriting an existing one. This is not advised as downstream services, such as DNS, will likely need updating.` ); } } else { if (existingLogicalId) { - Logger.warn( + Annotations.of(construct).addWarning( `GuStack has 'migratedFromCloudFormation' set to false. ${id} has an 'existingLogicalId' set to ${existingLogicalId}. This will have no effect - the logicalId will be auto-generated. Set 'migratedFromCloudFormation' to true for 'existingLogicalId' to be observed.` ); } if (isStateful) { - Logger.info( + Annotations.of(construct).addInfo( `GuStack has 'migratedFromCloudFormation' set to false. ${id} is a stateful construct, it's logicalId will be auto-generated and AWS will create a new resource.` ); } diff --git a/src/utils/mixin/migratable-construct-stateful.test.ts b/src/utils/mixin/migratable-construct-stateful.test.ts index 5dc41b7c20..bc68c8152b 100644 --- a/src/utils/mixin/migratable-construct-stateful.test.ts +++ b/src/utils/mixin/migratable-construct-stateful.test.ts @@ -1,9 +1,9 @@ import type { BucketProps } from "@aws-cdk/aws-s3"; import "../test/jest"; import { Bucket } from "@aws-cdk/aws-s3"; +import { Annotations } from "@aws-cdk/core"; import type { GuStack } from "../../constructs/core"; import type { GuMigratingResource } from "../../constructs/core/migrating"; -import { Logger } from "../logger"; import { simpleGuStackForTesting } from "../test"; import { GuStatefulMigratableConstruct } from "./migratable-construct-stateful"; @@ -16,7 +16,7 @@ class StatefulTestGuMigratableConstruct extends GuStatefulMigratableConstruct(Bu } describe("The GuStatefulMigratableConstruct mixin", () => { - const info = jest.spyOn(Logger, "info"); + const info = jest.spyOn(Annotations.prototype, "addInfo"); beforeEach(() => { info.mockReset();