diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js b/packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js index 0f88ddf3bd467..54eb8842eeee8 100755 --- a/packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js +++ b/packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js @@ -776,6 +776,15 @@ class AppSyncHotswapStack extends cdk.Stack { } } +class MetadataStack extends cdk.Stack { + constructor(parent, id, props) { + super(parent, id, props); + const handle = new cdk.CfnWaitConditionHandle(this, 'WaitConditionHandle'); + handle.addMetadata('Key', process.env.INTEG_METADATA_VALUE ?? 'default') + + } +} + const app = new cdk.App({ context: { '@aws-cdk/core:assetHashSalt': process.env.CODEBUILD_BUILD_ID, // Force all assets to be unique, but consistent in one build @@ -877,6 +886,8 @@ switch (stackSet) { new ExportValueStack(app, `${stackPrefix}-export-value-stack`); new BundlingStage(app, `${stackPrefix}-bundling-stage`); + + new MetadataStack(app, `${stackPrefix}-metadata`); break; case 'stage-using-context': diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index de888c9062f22..82f18672cfac2 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1064,6 +1064,46 @@ integTest( }), ); +integTest( + 'cdk diff doesnt show resource metadata changes', + withDefaultFixture(async (fixture) => { + + // GIVEN - small initial stack with default resource metadata + await fixture.cdkDeploy('metadata'); + + // WHEN - changing resource metadata value + const diff = await fixture.cdk(['diff', fixture.fullStackName('metadata')], { + verbose: true, + modEnv: { + INTEG_METADATA_VALUE: 'custom', + }, + }); + + // Assert there are no changes + expect(diff).toContain('There were no differences'); + }), +); + +integTest( + 'cdk diff shows resource metadata changes with --no-change-set', + withDefaultFixture(async (fixture) => { + + // GIVEN - small initial stack with default resource metadata + await fixture.cdkDeploy('metadata'); + + // WHEN - changing resource metadata value + const diff = await fixture.cdk(['diff --no-change-set', fixture.fullStackName('metadata')], { + verbose: true, + modEnv: { + INTEG_METADATA_VALUE: 'custom', + }, + }); + + // Assert there are changes + expect(diff).not.toContain('There were no differences'); + }), +); + integTest('cdk diff with large changeset and custom toolkit stack name and qualifier does not fail', withoutBootstrap(async (fixture) => { // Bootstrapping with custom toolkit stack name and qualifier const qualifier = 'abc1111'; diff --git a/packages/aws-cdk/lib/api/util/cloudformation.ts b/packages/aws-cdk/lib/api/util/cloudformation.ts index 79ac7cb461c1a..dcfe8a62dc6ef 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation.ts @@ -400,7 +400,6 @@ async function uploadBodyParameterAndCreateChangeSet( env.resolvedEnvironment, new AssetManifestBuilder(), env.resources, - env.sdk, ); const cfn = env.sdk.cloudFormation(); const exists = (await CloudFormationStack.lookup(cfn, options.stack.stackName, false)).exists;