From 37484726f235013ec0e71cefb9e1fc35caf12e74 Mon Sep 17 00:00:00 2001 From: SankyRed <121981451+SankyRed@users.noreply.github.com> Date: Thu, 16 May 2024 16:27:24 -0500 Subject: [PATCH 1/7] revert: "fix(diff): properties from ChangeSet diff were ignored" (#30243) Reverts: [30093](https://github.com/aws/aws-cdk/pull/30093) --- .../@aws-cdk-testing/cli-integ/lib/aws.ts | 2 - .../@aws-cdk-testing/cli-integ/package.json | 8 +- .../cli-integ/resources/cdk-apps/app/app.js | 18 - .../tests/cli-integ-tests/cli.integtest.ts | 44 --- .../cloudformation-diff/lib/diff-template.ts | 158 ++++----- .../cloudformation-diff/lib/diff/types.ts | 4 - .../test/diff-template.test.ts | 335 +----------------- .../@aws-cdk/cloudformation-diff/test/util.ts | 34 +- 8 files changed, 73 insertions(+), 530 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/aws.ts b/packages/@aws-cdk-testing/cli-integ/lib/aws.ts index cd06cad3b5e94..bcf19f4a47e3f 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/aws.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/aws.ts @@ -20,7 +20,6 @@ export class AwsClients { public readonly ecr: AwsCaller; public readonly ecs: AwsCaller; public readonly sso: AwsCaller; - public readonly ssm: AwsCaller; public readonly sns: AwsCaller; public readonly iam: AwsCaller; public readonly lambda: AwsCaller; @@ -40,7 +39,6 @@ export class AwsClients { this.ecs = makeAwsCaller(AWS.ECS, this.config); this.sso = makeAwsCaller(AWS.SSO, this.config); this.sns = makeAwsCaller(AWS.SNS, this.config); - this.ssm = makeAwsCaller(AWS.SSM, this.config); this.iam = makeAwsCaller(AWS.IAM, this.config); this.lambda = makeAwsCaller(AWS.Lambda, this.config); this.sts = makeAwsCaller(AWS.STS, this.config); diff --git a/packages/@aws-cdk-testing/cli-integ/package.json b/packages/@aws-cdk-testing/cli-integ/package.json index 28a49bf5f0c0c..c9fc053e059b3 100644 --- a/packages/@aws-cdk-testing/cli-integ/package.json +++ b/packages/@aws-cdk-testing/cli-integ/package.json @@ -30,12 +30,12 @@ "license": "Apache-2.0", "devDependencies": { "@aws-cdk/cdk-build-tools": "0.0.0", - "@aws-cdk/pkglint": "0.0.0", + "@types/semver": "^7.5.8", + "@types/yargs": "^15.0.19", "@types/fs-extra": "^9.0.13", "@types/glob": "^7.2.0", "@types/npm": "^7.19.3", - "@types/semver": "^7.5.8", - "@types/yargs": "^15.0.19" + "@aws-cdk/pkglint": "0.0.0" }, "dependencies": { "@octokit/rest": "^18.12.0", @@ -72,4 +72,4 @@ "publishConfig": { "tag": "latest" } -} +} \ No newline at end of file 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 5738eff1aa5f1..d094055795e27 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 @@ -126,22 +126,6 @@ class SsoInstanceAccessControlConfig extends Stack { } } -class DiffFromChangeSetStack extends Stack { - constructor(scope, id) { - super(scope, id); - - const queueNameFromParameter = ssm.StringParameter.valueForStringParameter(this, 'for-queue-name-defined-by-ssm-param'); - new sqs.Queue(this, "DiffFromChangeSetQueue", { - queueName: queueNameFromParameter, - }) - - new ssm.StringParameter(this, 'DiffFromChangeSetSSMParam', { - parameterName: 'DiffFromChangeSetSSMParamName', - stringValue: queueNameFromParameter, - }); - } -} - class ListMultipleDependentStack extends Stack { constructor(scope, id) { super(scope, id); @@ -701,8 +685,6 @@ switch (stackSet) { const failed = new FailedStack(app, `${stackPrefix}-failed`) - new DiffFromChangeSetStack(app, `${stackPrefix}-queue-name-defined-by-ssm-param`) - // A stack that depends on the failed stack -- used to test that '-e' does not deploy the failing stack const dependsOnFailed = new OutputsStack(app, `${stackPrefix}-depends-on-failed`); dependsOnFailed.addDependency(failed); 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 b80e3579b41d2..f323110eecfa4 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 @@ -944,50 +944,6 @@ integTest('cdk diff --quiet does not print \'There were no differences\' message expect(diff).not.toContain('There were no differences'); })); -integTest('cdk diff picks up changes that are only present in changeset', withDefaultFixture(async (fixture) => { - // GIVEN - await fixture.aws.ssm('putParameter', { - Name: 'for-queue-name-defined-by-ssm-param', - Value: randomString(), - Type: 'String', - Overwrite: true, - }); - - try { - await fixture.cdkDeploy('queue-name-defined-by-ssm-param'); - - // WHEN - // We want to change the ssm value. Then the CFN changeset will detect that the queue will be changed upon deploy. - await fixture.aws.ssm('putParameter', { - Name: 'for-queue-name-defined-by-ssm-param', - Value: randomString(), - Type: 'String', - Overwrite: true, - }); - - const diff = await fixture.cdk(['diff', fixture.fullStackName('queue-name-defined-by-ssm-param')]); - - // THEN - const normalizedPlainTextOutput = diff.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '') // remove all color and formatting (bolding, italic, etc) - .replace(/ /g, '') // remove all spaces - .replace(/\n/g, '') // remove all new lines - .replace(/\d+/g, ''); // remove all digits - - const normalizedExpectedOutput = ` - Resources - [~] AWS::SQS::Queue DiffFromChangeSetQueue DiffFromChangeSetQueue06622C07 replace - └─ [~] QueueName (requires replacement) - [~] AWS::SSM::Parameter DiffFromChangeSetSSMParam DiffFromChangeSetSSMParam92A9A723 - └─ [~] Value` - .replace(/ /g, '') - .replace(/\n/g, '') - .replace(/\d+/g, ''); - expect(normalizedPlainTextOutput).toContain(normalizedExpectedOutput); - } finally { - await fixture.cdkDestroy('queue-name-defined-by-ssm-param'); - } -})); - integTest('deploy stack with docker asset', withDefaultFixture(async (fixture) => { await fixture.cdkDeploy('docker'); })); diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts index 025a707b62386..118df03c6ebc5 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts @@ -55,7 +55,7 @@ export function fullDiff( normalize(newTemplate); const theDiff = diffTemplate(currentTemplate, newTemplate); if (changeSet) { - refineDiffWithChangeSet(theDiff, changeSet, newTemplate.Resources); + filterFalsePositives(theDiff, changeSet); addImportInformation(theDiff, changeSet); } else if (isImport) { makeAllResourceChangesImports(theDiff); @@ -143,6 +143,13 @@ function calculateTemplateDiff(currentTemplate: { [key: string]: any }, newTempl return new types.TemplateDiff(differences); } +/** + * Compare two CloudFormation resources and return semantic differences between them + */ +export function diffResource(oldValue: types.Resource, newValue: types.Resource): types.ResourceDifference { + return impl.diffResource(oldValue, newValue); +} + /** * Replace all references to the given logicalID on the given template, in-place * @@ -222,103 +229,45 @@ function makeAllResourceChangesImports(diff: types.TemplateDiff) { }); } -function refineDiffWithChangeSet(diff: types.TemplateDiff, changeSet: DescribeChangeSetOutput, newTemplateResources: {[logicalId: string]: any}) { - const replacements = _findResourceReplacements(changeSet); - - _addChangeSetResourcesToDiff(replacements, newTemplateResources); - _enhanceChangeImpacts(replacements); - return; - - function _findResourceReplacements(_changeSet: DescribeChangeSetOutput): types.ResourceReplacements { - const _replacements: types.ResourceReplacements = {}; - for (const resourceChange of _changeSet.Changes ?? []) { - const propertiesReplaced: { [propName: string]: types.ChangeSetReplacement } = {}; - for (const propertyChange of resourceChange.ResourceChange?.Details ?? []) { - if (propertyChange.Target?.Attribute === 'Properties') { - const requiresReplacement = propertyChange.Target.RequiresRecreation === 'Always'; - if (requiresReplacement && propertyChange.Evaluation === 'Static') { - propertiesReplaced[propertyChange.Target.Name!] = 'Always'; - } else if (requiresReplacement && propertyChange.Evaluation === 'Dynamic') { - // If Evaluation is 'Dynamic', then this may cause replacement, or it may not. - // see 'Replacement': https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ResourceChange.html - propertiesReplaced[propertyChange.Target.Name!] = 'Conditionally'; - } else { - propertiesReplaced[propertyChange.Target.Name!] = propertyChange.Target.RequiresRecreation as types.ChangeSetReplacement; - } - } - } - _replacements[resourceChange.ResourceChange?.LogicalResourceId!] = { - resourceReplaced: resourceChange.ResourceChange?.Replacement === 'True', - propertiesReplaced, - }; +function filterFalsePositives(diff: types.TemplateDiff, changeSet: DescribeChangeSetOutput) { + const replacements = findResourceReplacements(changeSet); + diff.resources.forEachDifference((logicalId: string, change: types.ResourceDifference) => { + if (change.resourceType.includes('AWS::Serverless')) { + // CFN applies the SAM transform before creating the changeset, so the changeset contains no information about SAM resources + return; } - - return _replacements; - } - - function _addChangeSetResourcesToDiff(_replacements: types.ResourceReplacements, _newTemplateResources: {[logicalId: string]: any}) { - const resourceDiffLogicalIds = diff.resources.logicalIds; - for (const logicalId of Object.keys(_replacements)) { - if (!(resourceDiffLogicalIds.includes(logicalId))) { - const noChangeResourceDiff = impl.diffResource(_newTemplateResources[logicalId], _newTemplateResources[logicalId]); - diff.resources.add(logicalId, noChangeResourceDiff); - } - - for (const propertyName of Object.keys(_replacements[logicalId].propertiesReplaced)) { - if (propertyName in diff.resources.get(logicalId).propertyUpdates) { - // If the property is already marked to be updated, then we don't need to do anything. - continue; + change.forEachDifference((type: 'Property' | 'Other', name: string, value: types.Difference | types.PropertyDifference) => { + if (type === 'Property') { + if (!replacements[logicalId]) { + (value as types.PropertyDifference).changeImpact = types.ResourceImpact.NO_CHANGE; + (value as types.PropertyDifference).isDifferent = false; + return; } - - const newProp = new types.PropertyDifference( - // these fields will be decided below - {}, {}, { changeImpact: undefined }, - ); - newProp.isDifferent = true; - diff.resources.get(logicalId).setPropertyChange(propertyName, newProp); - } - }; - } - - function _enhanceChangeImpacts(_replacements: types.ResourceReplacements) { - diff.resources.forEachDifference((logicalId: string, change: types.ResourceDifference) => { - if (change.resourceType.includes('AWS::Serverless')) { - // CFN applies the SAM transform before creating the changeset, so the changeset contains no information about SAM resources - return; - } - change.forEachDifference((type: 'Property' | 'Other', name: string, value: types.Difference | types.PropertyDifference) => { - if (type === 'Property') { - if (!_replacements[logicalId]) { + switch (replacements[logicalId].propertiesReplaced[name]) { + case 'Always': + (value as types.PropertyDifference).changeImpact = types.ResourceImpact.WILL_REPLACE; + break; + case 'Never': + (value as types.PropertyDifference).changeImpact = types.ResourceImpact.WILL_UPDATE; + break; + case 'Conditionally': + (value as types.PropertyDifference).changeImpact = types.ResourceImpact.MAY_REPLACE; + break; + case undefined: (value as types.PropertyDifference).changeImpact = types.ResourceImpact.NO_CHANGE; (value as types.PropertyDifference).isDifferent = false; - return; - } - switch (_replacements[logicalId].propertiesReplaced[name]) { - case 'Always': - (value as types.PropertyDifference).changeImpact = types.ResourceImpact.WILL_REPLACE; - break; - case 'Never': - (value as types.PropertyDifference).changeImpact = types.ResourceImpact.WILL_UPDATE; - break; - case 'Conditionally': - (value as types.PropertyDifference).changeImpact = types.ResourceImpact.MAY_REPLACE; - break; - case undefined: - (value as types.PropertyDifference).changeImpact = types.ResourceImpact.NO_CHANGE; - (value as types.PropertyDifference).isDifferent = false; - break; + break; // otherwise, defer to the changeImpact from `diffTemplate` - } - } else if (type === 'Other') { - switch (name) { - case 'Metadata': - change.setOtherChange('Metadata', new types.Difference(value.newValue, value.newValue)); - break; - } } - }); + } else if (type === 'Other') { + switch (name) { + case 'Metadata': + change.setOtherChange('Metadata', new types.Difference(value.newValue, value.newValue)); + break; + } + } }); - } + }); } function findResourceImports(changeSet: DescribeChangeSetOutput): string[] { @@ -332,6 +281,33 @@ function findResourceImports(changeSet: DescribeChangeSetOutput): string[] { return importedResourceLogicalIds; } +function findResourceReplacements(changeSet: DescribeChangeSetOutput): types.ResourceReplacements { + const replacements: types.ResourceReplacements = {}; + for (const resourceChange of changeSet.Changes ?? []) { + const propertiesReplaced: { [propName: string]: types.ChangeSetReplacement } = {}; + for (const propertyChange of resourceChange.ResourceChange?.Details ?? []) { + if (propertyChange.Target?.Attribute === 'Properties') { + const requiresReplacement = propertyChange.Target.RequiresRecreation === 'Always'; + if (requiresReplacement && propertyChange.Evaluation === 'Static') { + propertiesReplaced[propertyChange.Target.Name!] = 'Always'; + } else if (requiresReplacement && propertyChange.Evaluation === 'Dynamic') { + // If Evaluation is 'Dynamic', then this may cause replacement, or it may not. + // see 'Replacement': https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ResourceChange.html + propertiesReplaced[propertyChange.Target.Name!] = 'Conditionally'; + } else { + propertiesReplaced[propertyChange.Target.Name!] = propertyChange.Target.RequiresRecreation as types.ChangeSetReplacement; + } + } + } + replacements[resourceChange.ResourceChange?.LogicalResourceId!] = { + resourceReplaced: resourceChange.ResourceChange?.Replacement === 'True', + propertiesReplaced, + }; + } + + return replacements; +} + function normalize(template: any) { if (typeof template === 'object') { for (const key of (Object.keys(template ?? {}))) { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts index 9d66476c62852..4b65ef484e919 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts @@ -349,10 +349,6 @@ export class PropertyDifference extends Difference { export class DifferenceCollection> { constructor(private readonly diffs: { [logicalId: string]: T }) {} - public add(logicalId: string, diff: T): void { - this.diffs[logicalId] = diff; - } - public get changes(): { [logicalId: string]: T } { return onlyChanges(this.diffs); } diff --git a/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts b/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts index 5490d9051c22a..55b5a23753456 100644 --- a/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts +++ b/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts @@ -1,6 +1,5 @@ import * as fc from 'fast-check'; import { arbitraryTemplate } from './test-arbitraries'; -import { sqsQueue, sqsQueueWithAargs, ssmParam } from './util'; import { fullDiff, ResourceImpact } from '../lib/diff-template'; const POLICY_DOCUMENT = { foo: 'Bar' }; // Obviously a fake one! @@ -1232,336 +1231,4 @@ describe('changeset', () => { expect(differences.resources.differenceCount).toBe(1); expect(differences.resources.get('BucketResource').changeImpact === ResourceImpact.WILL_IMPORT); }); - - test('properties that only show up in changeset diff are included in fullDiff', () => { - // GIVEN - const currentTemplate = { - Parameters: { - SsmParameterValuetestbugreportC9: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'goodJob', - }, - }, - Resources: { - mySsmParameter: ssmParam, - }, - }; - - // WHEN - const diffWithoutChangeSet = fullDiff(currentTemplate, currentTemplate); - const diffWithChangeSet = fullDiff(currentTemplate, currentTemplate, - { - Changes: [ - { - Type: 'Resource', - ResourceChange: { - Action: 'Modify', - LogicalResourceId: 'mySsmParameter', - PhysicalResourceId: 'mySsmParameterFromStack', - ResourceType: 'AWS::SSM::Parameter', - Replacement: 'False', - Scope: ['Properties'], - Details: [{ - Target: { Attribute: 'Properties', Name: 'Value', RequiresRecreation: 'Never' }, - Evaluation: 'Static', - ChangeSource: 'DirectModification', - }], - }, - }, - ], - Parameters: [{ - ParameterKey: 'SsmParameterValuetestbugreportC9', - ParameterValue: 'goodJob', - ResolvedValue: 'changedVal', - }], - }, - ); - - // THEN - expect(diffWithoutChangeSet.differenceCount).toBe(0); - expect(diffWithoutChangeSet.resources.changes).toEqual({}); - - expect(diffWithChangeSet.differenceCount).toBe(1); - expect(diffWithChangeSet.resources.changes).toEqual( - { - mySsmParameter: { - oldValue: ssmParam, - newValue: ssmParam, - resourceTypes: { - oldType: 'AWS::SSM::Parameter', - newType: 'AWS::SSM::Parameter', - }, - propertyDiffs: { - Name: { - oldValue: 'mySsmParameterFromStack', - newValue: 'mySsmParameterFromStack', - isDifferent: false, - changeImpact: 'NO_CHANGE', - }, - Type: { - oldValue: 'String', - newValue: 'String', - isDifferent: false, - changeImpact: 'NO_CHANGE', - }, - Value: { - oldValue: {}, - newValue: {}, - isDifferent: true, - changeImpact: 'WILL_UPDATE', // this is what changed! - }, - }, - otherDiffs: { - Type: { - oldValue: 'AWS::SSM::Parameter', - newValue: 'AWS::SSM::Parameter', - isDifferent: false, - }, - }, - isAddition: false, - isRemoval: false, - isImport: undefined, - }, - }, - ); - }); - - test('resources that only show up in changeset diff are included in fullDiff', () => { - // GIVEN - const currentTemplate = { - Parameters: { - SsmParameterValuetestbugreportC9: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'goodJob', - }, - }, - Resources: { - Queue: { - Type: 'AWS::SQS::Queue', - Properties: { - QueueName: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - }, - }, - }, - }; - - // WHEN - const diffWithoutChangeSet = fullDiff(currentTemplate, currentTemplate); - const diffWithChangeSet = fullDiff(currentTemplate, currentTemplate, - { - Changes: [ - { - Type: 'Resource', - ResourceChange: { - PolicyAction: 'ReplaceAndDelete', - Action: 'Modify', - LogicalResourceId: 'Queue', - PhysicalResourceId: 'https://sqs.us-east-1.amazonaws.com/012345678901/hiii', - ResourceType: 'AWS::SQS::Queue', - Replacement: 'True', - Scope: ['Properties'], - Details: [{ - Target: { Attribute: 'Properties', Name: 'QueueName', RequiresRecreation: 'Always' }, - Evaluation: 'Static', - ChangeSource: 'DirectModification', - }], - }, - }, - ], - Parameters: [{ - ParameterKey: 'SsmParameterValuetestbugreportC9', - ParameterValue: 'goodJob', - ResolvedValue: 'changedVal', - }], - }, - ); - - // THEN - expect(diffWithoutChangeSet.differenceCount).toBe(0); - expect(diffWithoutChangeSet.resources.changes).toEqual({}); - - expect(diffWithChangeSet.differenceCount).toBe(1); - expect(diffWithChangeSet.resources.changes).toEqual( - { - Queue: { - oldValue: sqsQueue, - newValue: sqsQueue, - resourceTypes: { - oldType: 'AWS::SQS::Queue', - newType: 'AWS::SQS::Queue', - }, - propertyDiffs: { - QueueName: { - oldValue: {}, - newValue: {}, - isDifferent: true, - changeImpact: 'WILL_REPLACE', // this is what changed! - }, - }, - otherDiffs: { - Type: { - oldValue: 'AWS::SQS::Queue', - newValue: 'AWS::SQS::Queue', - isDifferent: false, - }, - }, - isAddition: false, - isRemoval: false, - isImport: undefined, - }, - }, - ); - }); - - test('a resource in the diff that is missing a property has the missing property added to the diff', () => { - // The idea is, we detect 1 change in the template diff -- and we detect another change in the changeset diff. - - // GIVEN - const currentTemplate = { - Parameters: { - SsmParameterValuetestbugreportC9: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'goodJob', - }, - }, - Resources: { - Queue: sqsQueueWithAargs({ waitTime: 10 }), - }, - }; - - const newTemplate = { - Parameters: { - SsmParameterValuetestbugreportC9: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'goodJob', - }, - }, - Resources: { - Queue: sqsQueueWithAargs({ waitTime: 20 }), - }, - }; - - // WHEN - const diffWithoutChangeSet = fullDiff(currentTemplate, newTemplate); - const diffWithChangeSet = fullDiff(currentTemplate, newTemplate, - { - Changes: [ - { - Type: 'Resource', - ResourceChange: { - PolicyAction: 'ReplaceAndDelete', - Action: 'Modify', - LogicalResourceId: 'Queue', - PhysicalResourceId: 'https://sqs.us-east-1.amazonaws.com/012345678901/newValueNEEEWWWEEERRRRR', - ResourceType: 'AWS::SQS::Queue', - Replacement: 'True', - Scope: [ - 'Properties', - ], - Details: [{ - Target: { Attribute: 'Properties', Name: 'QueueName', RequiresRecreation: 'Always' }, - Evaluation: 'Static', - ChangeSource: 'DirectModification', - }, - { - Target: { Attribute: 'Properties', Name: 'ReceiveMessageWaitTimeSeconds', RequiresRecreation: 'Never' }, - Evaluation: 'Static', - ChangeSource: 'DirectModification', - }], - }, - }, - ], - Parameters: [{ - ParameterKey: 'SsmParameterValuetestbugreportC9', - ParameterValue: 'goodJob', - ResolvedValue: 'changedddd', - }], - }, - ); - - // THEN - expect(diffWithoutChangeSet.differenceCount).toBe(1); - expect(diffWithoutChangeSet.resources.changes).toEqual( - { - Queue: { - oldValue: sqsQueueWithAargs({ waitTime: 10 }), - newValue: sqsQueueWithAargs({ waitTime: 20 }), - resourceTypes: { - oldType: 'AWS::SQS::Queue', - newType: 'AWS::SQS::Queue', - }, - propertyDiffs: { - QueueName: { - oldValue: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - newValue: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - isDifferent: false, - changeImpact: 'NO_CHANGE', - }, - ReceiveMessageWaitTimeSeconds: { - oldValue: 10, - newValue: 20, - isDifferent: true, - changeImpact: 'WILL_UPDATE', - }, - }, - otherDiffs: { - Type: { - oldValue: 'AWS::SQS::Queue', - newValue: 'AWS::SQS::Queue', - isDifferent: false, - }, - }, - isAddition: false, - isRemoval: false, - isImport: undefined, - }, - }, - ); - - expect(diffWithChangeSet.differenceCount).toBe(1); // this is the count of how many resources have changed - expect(diffWithChangeSet.resources.changes).toEqual( - { - Queue: { - oldValue: sqsQueueWithAargs({ waitTime: 10 }), - newValue: sqsQueueWithAargs({ waitTime: 20 }), - resourceTypes: { - oldType: 'AWS::SQS::Queue', - newType: 'AWS::SQS::Queue', - }, - propertyDiffs: { - QueueName: { - oldValue: { - }, - newValue: { - }, - isDifferent: true, - changeImpact: 'WILL_REPLACE', - }, - ReceiveMessageWaitTimeSeconds: { - oldValue: 10, - newValue: 20, - isDifferent: true, - changeImpact: 'WILL_UPDATE', - }, - }, - otherDiffs: { - Type: { - oldValue: 'AWS::SQS::Queue', - newValue: 'AWS::SQS::Queue', - isDifferent: false, - }, - }, - isAddition: false, - isRemoval: false, - isImport: undefined, - }, - }, - ); - }); -}); +}); \ No newline at end of file diff --git a/packages/@aws-cdk/cloudformation-diff/test/util.ts b/packages/@aws-cdk/cloudformation-diff/test/util.ts index 9c1bb4d4dfaed..08e4afc48eafb 100644 --- a/packages/@aws-cdk/cloudformation-diff/test/util.ts +++ b/packages/@aws-cdk/cloudformation-diff/test/util.ts @@ -72,36 +72,4 @@ export function largeSsoPermissionSet() { }, ), }); -} - -export const ssmParam = { - Type: 'AWS::SSM::Parameter', - Properties: { - Name: 'mySsmParameterFromStack', - Type: 'String', - Value: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - }, -}; - -export const sqsQueue = { - Type: 'AWS::SQS::Queue', - Properties: { - QueueName: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - }, -}; - -export function sqsQueueWithAargs(args: { waitTime: number }) { - return { - Type: 'AWS::SQS::Queue', - Properties: { - QueueName: { - Ref: 'SsmParameterValuetestbugreportC9', - }, - ReceiveMessageWaitTimeSeconds: args.waitTime, - }, - }; -} +} \ No newline at end of file From 39225bcd99a7a71f7f9757a07e4b359d7a48e09d Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 17:55:08 -0500 Subject: [PATCH 2/7] fix integ tests for old tests with new changes --- .../resources/cli-regression-patches/v2.142.0/NOTES.md | 1 + .../resources/cli-regression-patches/v2.142.0/skip-tests.txt | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/NOTES.md create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/NOTES.md b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/NOTES.md new file mode 100644 index 0000000000000..a606d9cd2b28e --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/NOTES.md @@ -0,0 +1 @@ +This patch brings the [fix](https://github.com/aws/aws-cdk/issues/30241) into the regression suite. \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt new file mode 100644 index 0000000000000..722598fe60dca --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt @@ -0,0 +1,4 @@ +# Skipping the test to fix issue https://github.com/aws/aws-cdk/issues/30241. +# cli-integ tests failing for the old tests with the new cli changes for list stacks. + +cdk diff picks up changes that are only present in changeset \ No newline at end of file From b61d7c46edf3ed2e20c18f4a8c54eaf685149465 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 18:05:06 -0500 Subject: [PATCH 3/7] clean up --- .../resources/cli-regression-patches/v2.142.0/skip-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt index 722598fe60dca..0351c9fb93703 100644 --- a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.142.0/skip-tests.txt @@ -1,4 +1,4 @@ # Skipping the test to fix issue https://github.com/aws/aws-cdk/issues/30241. -# cli-integ tests failing for the old tests with the new cli changes for list stacks. +# cli-integ tests failing for the old tests with the new cli changes for diff stacks. cdk diff picks up changes that are only present in changeset \ No newline at end of file From 1c0daa5511e4e1deca3337a460e29efa1518446d Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 20:28:38 -0500 Subject: [PATCH 4/7] chore(release): 2.142.1 --- CHANGELOG.v2.alpha.md | 2 ++ CHANGELOG.v2.md | 7 +++++++ version.v2.json | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 858ac0810b88c..ed8481acf157f 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.142.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.142.0-alpha.0...v2.142.1-alpha.0) (2024-05-17) + ## [2.142.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.141.0-alpha.0...v2.142.0-alpha.0) (2024-05-15) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index c6331e662ec09..a9e11251740f3 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.142.1](https://github.com/aws/aws-cdk/compare/v2.142.0...v2.142.1) (2024-05-17) + + +### Reverts + +* "fix(diff): properties from ChangeSet diff were ignored" ([#30243](https://github.com/aws/aws-cdk/issues/30243)) ([3748472](https://github.com/aws/aws-cdk/commit/37484726f235013ec0e71cefb9e1fc35caf12e74)) + ## [2.142.0](https://github.com/aws/aws-cdk/compare/v2.141.0...v2.142.0) (2024-05-15) diff --git a/version.v2.json b/version.v2.json index 004aacd35c9e1..6167b28a1dcd9 100644 --- a/version.v2.json +++ b/version.v2.json @@ -1,4 +1,4 @@ { - "version": "2.142.0", - "alphaVersion": "2.142.0-alpha.0" + "version": "2.142.1", + "alphaVersion": "2.142.1-alpha.0" } \ No newline at end of file From 121fd4ff4a9c7329a798f43c03642da9c59f972e Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 20:49:18 -0500 Subject: [PATCH 5/7] clean changelog and alpha changelog --- CHANGELOG.v2.alpha.md | 2 +- CHANGELOG.v2.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index ed8481acf157f..ddccfc0f47aa3 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [2.142.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.142.0-alpha.0...v2.142.1-alpha.0) (2024-05-17) +## [2.142.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.142.0-alpha.0...v2.142.1-alpha.0) (2024-05-17) ## [2.142.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.141.0-alpha.0...v2.142.0-alpha.0) (2024-05-15) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index a9e11251740f3..30cb5d7f5d08c 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,12 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [2.142.1](https://github.com/aws/aws-cdk/compare/v2.142.0...v2.142.1) (2024-05-17) +## [2.142.1](https://github.com/aws/aws-cdk/compare/v2.142.0...v2.142.1) (2024-05-17) ### Reverts * "fix(diff): properties from ChangeSet diff were ignored" ([#30243](https://github.com/aws/aws-cdk/issues/30243)) ([3748472](https://github.com/aws/aws-cdk/commit/37484726f235013ec0e71cefb9e1fc35caf12e74)) +* "chore(cli): skipping old cli integ test cdk diff changes in change set for new changes" ([#30245](https://github.com/aws/aws-cdk/issues/30245)) ([1ba6e87](https://github.com/aws/aws-cdk/commit/1ba6e87fb2cb4fab0da81c4d21912d05dd2e964b)), closes [aws/aws-cdk#30241](https://github.com/aws/aws-cdk/issues/30241) ## [2.142.0](https://github.com/aws/aws-cdk/compare/v2.141.0...v2.142.0) (2024-05-15) From 068bae62234b8bf0d2d23ff075fa5c3f17a41347 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 20:57:30 -0500 Subject: [PATCH 6/7] update changelog --- CHANGELOG.v2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 30cb5d7f5d08c..7b48a2f46f4b5 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -7,8 +7,8 @@ All notable changes to this project will be documented in this file. See [standa ### Reverts -* "fix(diff): properties from ChangeSet diff were ignored" ([#30243](https://github.com/aws/aws-cdk/issues/30243)) ([3748472](https://github.com/aws/aws-cdk/commit/37484726f235013ec0e71cefb9e1fc35caf12e74)) -* "chore(cli): skipping old cli integ test cdk diff changes in change set for new changes" ([#30245](https://github.com/aws/aws-cdk/issues/30245)) ([1ba6e87](https://github.com/aws/aws-cdk/commit/1ba6e87fb2cb4fab0da81c4d21912d05dd2e964b)), closes [aws/aws-cdk#30241](https://github.com/aws/aws-cdk/issues/30241) +* fix(diff): properties from ChangeSet diff were ignored ([#30243](https://github.com/aws/aws-cdk/issues/30243)) ([3748472](https://github.com/aws/aws-cdk/commit/37484726f235013ec0e71cefb9e1fc35caf12e74)) +* chore(cli): skipping old cli integ test cdk diff changes in change set for new changes ([#30245](https://github.com/aws/aws-cdk/issues/30245)) ([1ba6e87](https://github.com/aws/aws-cdk/commit/1ba6e87fb2cb4fab0da81c4d21912d05dd2e964b)), closes [aws/aws-cdk#30241](https://github.com/aws/aws-cdk/issues/30241) ## [2.142.0](https://github.com/aws/aws-cdk/compare/v2.141.0...v2.142.0) (2024-05-15) From c0dd7e03604531977d43b4a143d00bd20a7c5af7 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 16 May 2024 20:58:30 -0500 Subject: [PATCH 7/7] clean up --- CHANGELOG.v2.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 7b48a2f46f4b5..00a83f9f79a5c 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -8,7 +8,6 @@ All notable changes to this project will be documented in this file. See [standa ### Reverts * fix(diff): properties from ChangeSet diff were ignored ([#30243](https://github.com/aws/aws-cdk/issues/30243)) ([3748472](https://github.com/aws/aws-cdk/commit/37484726f235013ec0e71cefb9e1fc35caf12e74)) -* chore(cli): skipping old cli integ test cdk diff changes in change set for new changes ([#30245](https://github.com/aws/aws-cdk/issues/30245)) ([1ba6e87](https://github.com/aws/aws-cdk/commit/1ba6e87fb2cb4fab0da81c4d21912d05dd2e964b)), closes [aws/aws-cdk#30241](https://github.com/aws/aws-cdk/issues/30241) ## [2.142.0](https://github.com/aws/aws-cdk/compare/v2.141.0...v2.142.0) (2024-05-15)