From 8948ecb22627ef57498e68fb721b0598aaa530ee Mon Sep 17 00:00:00 2001 From: Sumu Pitchayan <35242245+sumupitchayan@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:07:30 -0500 Subject: [PATCH 1/4] fix(aspects): "localAspects is not iterable" error (#32647) Closes #32470 ### Reason for this change Some customers have reported seeing the error `TypeError: localAspects is not iterable` upon upgrading to CDK v2.172.0 (this is when the Priority-ordered aspects feature was released). This is likely caused by customers having dependencies on third-party constructs/libraries which are using outdated versions (< 2.172.0) of CDK. The problem more specifically is that the `Aspects.applied` function was added in v2.172.0, and the new `invokeAspects` function calls this function on all nodes in the tree. ### Description of changes Created a workaround for customers. Added the `getAspectApplications` function in `synthesis.ts` - this function creates `AspectApplication` objects from `Aspects.all` if `Aspects.applied` does not exist. ### Describe any new or updated permissions being added None. ### Description of how you validated changes New unit test in `aspect.test.ts` with a monkey patched `Aspects.applied` function. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk-lib/core/lib/private/synthesis.ts | 22 +++++++++++++++---- packages/aws-cdk-lib/core/test/aspect.test.ts | 20 +++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/core/lib/private/synthesis.ts b/packages/aws-cdk-lib/core/lib/private/synthesis.ts index 320f3cadf8eaf..494923495a02f 100644 --- a/packages/aws-cdk-lib/core/lib/private/synthesis.ts +++ b/packages/aws-cdk-lib/core/lib/private/synthesis.ts @@ -8,7 +8,7 @@ import { CloudAssembly } from '../../../cx-api'; import * as cxapi from '../../../cx-api'; import { Annotations } from '../annotations'; import { App } from '../app'; -import { AspectApplication, Aspects } from '../aspect'; +import { AspectApplication, AspectPriority, Aspects } from '../aspect'; import { FileSystem } from '../fs'; import { Stack } from '../stack'; import { ISynthesisSession } from '../stack-synthesizers/types'; @@ -228,7 +228,7 @@ function invokeAspects(root: IConstruct) { const node = construct.node; const aspects = Aspects.of(construct); - let localAspects = aspects.applied; + let localAspects = getAspectApplications(construct); const allAspectsHere = sortAspectsByPriority(inheritedAspects, localAspects); const nodeAspectsCount = aspects.all.length; @@ -290,11 +290,10 @@ function invokeAspectsV2(root: IConstruct) { function recurse(construct: IConstruct, inheritedAspects: AspectApplication[]): boolean { const node = construct.node; - const aspects = Aspects.of(construct); let didSomething = false; - let localAspects = aspects.applied; + let localAspects = getAspectApplications(construct); const allAspectsHere = sortAspectsByPriority(inheritedAspects, localAspects); for (const aspectApplication of allAspectsHere) { @@ -354,6 +353,21 @@ function sortAspectsByPriority(inheritedAspects: AspectApplication[], localAspec return allAspects; } +/** + * Helper function to get aspect applications. + * If `Aspects.applied` is available, it is used; otherwise, create AspectApplications from `Aspects.all`. + */ +function getAspectApplications(node: IConstruct): AspectApplication[] { + const aspects = Aspects.of(node); + if (aspects.applied !== undefined) { + return aspects.applied; + } + + // Fallback: Create AspectApplications from `aspects.all` + const typedAspects = aspects as Aspects; + return typedAspects.all.map(aspect => new AspectApplication(node, aspect, AspectPriority.DEFAULT)); +} + /** * Find all stacks and add Metadata Resources to all of them * diff --git a/packages/aws-cdk-lib/core/test/aspect.test.ts b/packages/aws-cdk-lib/core/test/aspect.test.ts index f27837a9f7c62..865f17b031dc0 100644 --- a/packages/aws-cdk-lib/core/test/aspect.test.ts +++ b/packages/aws-cdk-lib/core/test/aspect.test.ts @@ -309,4 +309,24 @@ describe('aspect', () => { } } } + + test.each([ + { stabilization: true }, + { stabilization: false }, + ])('Error is not thrown if Aspects.applied does not exist (stabilization: $stabilization)', ({ stabilization }) => { + const app = new App({ context: { '@aws-cdk/core:aspectStabilization': stabilization } }); + const root = new Stack(app, 'My-Stack'); + + Aspects.of(root).add(new Tag('AspectA', 'Visited')); + + // "Monkey patching" - Override `applied` to simulate its absence + Object.defineProperty(Aspects.prototype, 'applied', { + value: undefined, + configurable: true, + }); + + expect(() => { + app.synth(); + }).not.toThrow(); + }); }); From c29a3ab83416c1626573be4be0b2c037ef24ee3a Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <zen.conroy@gmail.com> Date: Thu, 26 Dec 2024 10:59:49 -0600 Subject: [PATCH 2/4] chore(release): 2.173.3 --- CHANGELOG.v2.alpha.md | 13 +++++++++++++ CHANGELOG.v2.md | 29 +++++++++++++++++++++++++++++ version.v2.json | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index c937b3a65832b..697ba2bb0401a 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,6 +2,19 @@ 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.173.3-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.2-alpha.0...v2.173.3-alpha.0) (2024-12-26) + + +### Features + +* **glue:** support AWS Glue 5.0 ([#32467](https://github.com/aws/aws-cdk/issues/32467)) ([ca01a25](https://github.com/aws/aws-cdk/commit/ca01a25d1328685fc9a362a1e2cbe7738389956c)) + + +### Bug Fixes + +* **ec2-alpha:** do not use string comparison in `rangesOverlap` ([#32269](https://github.com/aws/aws-cdk/issues/32269)) ([87e21d6](https://github.com/aws/aws-cdk/commit/87e21d625af86873716734dd5568940d41096c45)), closes [#32145](https://github.com/aws/aws-cdk/issues/32145) [#32145](https://github.com/aws/aws-cdk/issues/32145) +* **redshift-alpha:** extract tableName from custom resource functions ([#32452](https://github.com/aws/aws-cdk/issues/32452)) ([283edd6](https://github.com/aws/aws-cdk/commit/283edd6601ac54cf868213d68edb7c76b3a45223)), closes [PR#24308](https://github.com/aws/PR/issues/24308) + ## [2.173.2-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.1-alpha.0...v2.173.2-alpha.0) (2024-12-17) ## [2.173.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.0-alpha.0...v2.173.1-alpha.0) (2024-12-14) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index bfe3129111fe4..54f6ef84fe56d 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,6 +2,35 @@ 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.173.3](https://github.com/aws/aws-cdk/compare/v2.173.2...v2.173.3) (2024-12-26) + + +### Features + +* **appconfig:** add atDeploymentTick extension action point to L2 Constructs ([#32490](https://github.com/aws/aws-cdk/issues/32490)) ([225d261](https://github.com/aws/aws-cdk/commit/225d261bf2d8f4ada3ac06de9f9f11e4586510b2)) +* **cloudfront:** distribution ARN property ([#32531](https://github.com/aws/aws-cdk/issues/32531)) ([b7e6141](https://github.com/aws/aws-cdk/commit/b7e6141dbb6b55a36bb3590a0cdadef2c478a348)), closes [#32530](https://github.com/aws/aws-cdk/issues/32530) +* **codebuild:** support auto retry limit for Project ([#32507](https://github.com/aws/aws-cdk/issues/32507)) ([2c109cf](https://github.com/aws/aws-cdk/commit/2c109cf3b5bff9cb53ba70889ee60aaa602430f1)), closes [#32446](https://github.com/aws/aws-cdk/issues/32446) +* **ecs:** machineImageType support AL2023 ([#32509](https://github.com/aws/aws-cdk/issues/32509)) ([4b696bc](https://github.com/aws/aws-cdk/commit/4b696bc338ec0048e202201273f5220ff40a7e8f)), closes [#32496](https://github.com/aws/aws-cdk/issues/32496) [#32469](https://github.com/aws/aws-cdk/issues/32469) +* update L1 CloudFormation resource definitions ([#32540](https://github.com/aws/aws-cdk/issues/32540)) ([2e3b2ac](https://github.com/aws/aws-cdk/commit/2e3b2ac51c459e4d8a4bc7e6f488e2bab433cea7)) + + +### Bug Fixes + +* **aspects:** "localAspects is not iterable" error ([#32647](https://github.com/aws/aws-cdk/issues/32647)) ([8948ecb](https://github.com/aws/aws-cdk/commit/8948ecb22627ef57498e68fb721b0598aaa530ee)), closes [#32470](https://github.com/aws/aws-cdk/issues/32470) +* **cdk:** changed retry mechanism for hotswapping AppSync.function ([#32179](https://github.com/aws/aws-cdk/issues/32179)) ([d14d784](https://github.com/aws/aws-cdk/commit/d14d784c30bb0cb70beb2405b1042157aaa0a4e1)) +* **cli:** allow credential plugins to return `null` for `expiration` ([#32554](https://github.com/aws/aws-cdk/issues/32554)) ([d4f6946](https://github.com/aws/aws-cdk/commit/d4f6946dbc97161749a33d3e89514a8f7ca4aa0a)) +* **cli:** cdk deploy -R does not disable rollback ([#32514](https://github.com/aws/aws-cdk/issues/32514)) ([2e75924](https://github.com/aws/aws-cdk/commit/2e759243cfb7a6c2e72f57abf31703ea8ed9ac12)), closes [#31850](https://github.com/aws/aws-cdk/issues/31850) +* **cli:** doesn't support plugins that return initially empty credentials ([#32552](https://github.com/aws/aws-cdk/issues/32552)) ([38116b0](https://github.com/aws/aws-cdk/commit/38116b0ce7afda179c0067dfc5f19f24409f7fbe)) +* **cli:** getting credentials via SSO fails when the region is set in the profile ([#32520](https://github.com/aws/aws-cdk/issues/32520)) ([bf026bd](https://github.com/aws/aws-cdk/commit/bf026bdd8557305d427510af49f1bc538d439cb6)) +* **lambda:** add [@deprecated](https://github.com/deprecated) tag to python3.8 ([#32162](https://github.com/aws/aws-cdk/issues/32162)) ([27619cc](https://github.com/aws/aws-cdk/commit/27619cc401829a851f211e0b7e81fcf84c5cbd44)) +* **route53-targets:** deprecated method for dns name is used in userpool domain target (under feature flag) ([#31403](https://github.com/aws/aws-cdk/issues/31403)) ([5e73dd0](https://github.com/aws/aws-cdk/commit/5e73dd089360a999cd86920b6d42bf69b1c0ded1)) + + +### Reverts + +* "chore(release): 2.174.0" ([#32662](https://github.com/aws/aws-cdk/issues/32662)) ([3055717](https://github.com/aws/aws-cdk/commit/3055717a185e7a62aa22f8150ab805c71bd9b782)), closes [aws/aws-cdk#32591](https://github.com/aws/aws-cdk/issues/32591) +* **ecs:** machineImageType support AL2023 ([#32550](https://github.com/aws/aws-cdk/issues/32550)) ([e8d8237](https://github.com/aws/aws-cdk/commit/e8d823797c5020193bfe2c6fef39369057717298)), closes [aws/aws-cdk#32509](https://github.com/aws/aws-cdk/issues/32509) + ## [2.173.2](https://github.com/aws/aws-cdk/compare/v2.173.1...v2.173.2) (2024-12-17) diff --git a/version.v2.json b/version.v2.json index e4c6ace5a1c12..e42ef2fcd4997 100644 --- a/version.v2.json +++ b/version.v2.json @@ -1,4 +1,4 @@ { - "version": "2.173.2", - "alphaVersion": "2.173.2-alpha.0" + "version": "2.173.3", + "alphaVersion": "2.173.3-alpha.0" } \ No newline at end of file From c9e4ebc73be084e9978dee71fd7f7a4f26823020 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <zen.conroy@gmail.com> Date: Thu, 26 Dec 2024 11:04:05 -0600 Subject: [PATCH 3/4] chore(changelog): fixup changelog --- CHANGELOG.v2.alpha.md | 11 ----------- CHANGELOG.v2.md | 22 ---------------------- 2 files changed, 33 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 697ba2bb0401a..73ba707082f31 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -4,17 +4,6 @@ All notable changes to this project will be documented in this file. See [standa ### [2.173.3-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.2-alpha.0...v2.173.3-alpha.0) (2024-12-26) - -### Features - -* **glue:** support AWS Glue 5.0 ([#32467](https://github.com/aws/aws-cdk/issues/32467)) ([ca01a25](https://github.com/aws/aws-cdk/commit/ca01a25d1328685fc9a362a1e2cbe7738389956c)) - - -### Bug Fixes - -* **ec2-alpha:** do not use string comparison in `rangesOverlap` ([#32269](https://github.com/aws/aws-cdk/issues/32269)) ([87e21d6](https://github.com/aws/aws-cdk/commit/87e21d625af86873716734dd5568940d41096c45)), closes [#32145](https://github.com/aws/aws-cdk/issues/32145) [#32145](https://github.com/aws/aws-cdk/issues/32145) -* **redshift-alpha:** extract tableName from custom resource functions ([#32452](https://github.com/aws/aws-cdk/issues/32452)) ([283edd6](https://github.com/aws/aws-cdk/commit/283edd6601ac54cf868213d68edb7c76b3a45223)), closes [PR#24308](https://github.com/aws/PR/issues/24308) - ## [2.173.2-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.1-alpha.0...v2.173.2-alpha.0) (2024-12-17) ## [2.173.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.0-alpha.0...v2.173.1-alpha.0) (2024-12-14) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 54f6ef84fe56d..f2aabe392923a 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -5,31 +5,9 @@ All notable changes to this project will be documented in this file. See [standa ### [2.173.3](https://github.com/aws/aws-cdk/compare/v2.173.2...v2.173.3) (2024-12-26) -### Features - -* **appconfig:** add atDeploymentTick extension action point to L2 Constructs ([#32490](https://github.com/aws/aws-cdk/issues/32490)) ([225d261](https://github.com/aws/aws-cdk/commit/225d261bf2d8f4ada3ac06de9f9f11e4586510b2)) -* **cloudfront:** distribution ARN property ([#32531](https://github.com/aws/aws-cdk/issues/32531)) ([b7e6141](https://github.com/aws/aws-cdk/commit/b7e6141dbb6b55a36bb3590a0cdadef2c478a348)), closes [#32530](https://github.com/aws/aws-cdk/issues/32530) -* **codebuild:** support auto retry limit for Project ([#32507](https://github.com/aws/aws-cdk/issues/32507)) ([2c109cf](https://github.com/aws/aws-cdk/commit/2c109cf3b5bff9cb53ba70889ee60aaa602430f1)), closes [#32446](https://github.com/aws/aws-cdk/issues/32446) -* **ecs:** machineImageType support AL2023 ([#32509](https://github.com/aws/aws-cdk/issues/32509)) ([4b696bc](https://github.com/aws/aws-cdk/commit/4b696bc338ec0048e202201273f5220ff40a7e8f)), closes [#32496](https://github.com/aws/aws-cdk/issues/32496) [#32469](https://github.com/aws/aws-cdk/issues/32469) -* update L1 CloudFormation resource definitions ([#32540](https://github.com/aws/aws-cdk/issues/32540)) ([2e3b2ac](https://github.com/aws/aws-cdk/commit/2e3b2ac51c459e4d8a4bc7e6f488e2bab433cea7)) - - ### Bug Fixes * **aspects:** "localAspects is not iterable" error ([#32647](https://github.com/aws/aws-cdk/issues/32647)) ([8948ecb](https://github.com/aws/aws-cdk/commit/8948ecb22627ef57498e68fb721b0598aaa530ee)), closes [#32470](https://github.com/aws/aws-cdk/issues/32470) -* **cdk:** changed retry mechanism for hotswapping AppSync.function ([#32179](https://github.com/aws/aws-cdk/issues/32179)) ([d14d784](https://github.com/aws/aws-cdk/commit/d14d784c30bb0cb70beb2405b1042157aaa0a4e1)) -* **cli:** allow credential plugins to return `null` for `expiration` ([#32554](https://github.com/aws/aws-cdk/issues/32554)) ([d4f6946](https://github.com/aws/aws-cdk/commit/d4f6946dbc97161749a33d3e89514a8f7ca4aa0a)) -* **cli:** cdk deploy -R does not disable rollback ([#32514](https://github.com/aws/aws-cdk/issues/32514)) ([2e75924](https://github.com/aws/aws-cdk/commit/2e759243cfb7a6c2e72f57abf31703ea8ed9ac12)), closes [#31850](https://github.com/aws/aws-cdk/issues/31850) -* **cli:** doesn't support plugins that return initially empty credentials ([#32552](https://github.com/aws/aws-cdk/issues/32552)) ([38116b0](https://github.com/aws/aws-cdk/commit/38116b0ce7afda179c0067dfc5f19f24409f7fbe)) -* **cli:** getting credentials via SSO fails when the region is set in the profile ([#32520](https://github.com/aws/aws-cdk/issues/32520)) ([bf026bd](https://github.com/aws/aws-cdk/commit/bf026bdd8557305d427510af49f1bc538d439cb6)) -* **lambda:** add [@deprecated](https://github.com/deprecated) tag to python3.8 ([#32162](https://github.com/aws/aws-cdk/issues/32162)) ([27619cc](https://github.com/aws/aws-cdk/commit/27619cc401829a851f211e0b7e81fcf84c5cbd44)) -* **route53-targets:** deprecated method for dns name is used in userpool domain target (under feature flag) ([#31403](https://github.com/aws/aws-cdk/issues/31403)) ([5e73dd0](https://github.com/aws/aws-cdk/commit/5e73dd089360a999cd86920b6d42bf69b1c0ded1)) - - -### Reverts - -* "chore(release): 2.174.0" ([#32662](https://github.com/aws/aws-cdk/issues/32662)) ([3055717](https://github.com/aws/aws-cdk/commit/3055717a185e7a62aa22f8150ab805c71bd9b782)), closes [aws/aws-cdk#32591](https://github.com/aws/aws-cdk/issues/32591) -* **ecs:** machineImageType support AL2023 ([#32550](https://github.com/aws/aws-cdk/issues/32550)) ([e8d8237](https://github.com/aws/aws-cdk/commit/e8d823797c5020193bfe2c6fef39369057717298)), closes [aws/aws-cdk#32509](https://github.com/aws/aws-cdk/issues/32509) ## [2.173.2](https://github.com/aws/aws-cdk/compare/v2.173.1...v2.173.2) (2024-12-17) From 2e198d4ba1f5e25f1a9db056d637c1971d6faed2 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <zen.conroy@gmail.com> Date: Thu, 26 Dec 2024 11:05:59 -0600 Subject: [PATCH 4/4] chore(changelog): fix up inconsistencies --- CHANGELOG.v2.alpha.md | 2 +- CHANGELOG.v2.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 73ba707082f31..9b03d17525dc7 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.173.3-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.2-alpha.0...v2.173.3-alpha.0) (2024-12-26) +## [2.173.3-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.2-alpha.0...v2.173.3-alpha.0) (2024-12-26) ## [2.173.2-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.1-alpha.0...v2.173.2-alpha.0) (2024-12-17) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index f2aabe392923a..43dff9bac972e 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.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.173.3](https://github.com/aws/aws-cdk/compare/v2.173.2...v2.173.3) (2024-12-26) +## [2.173.3](https://github.com/aws/aws-cdk/compare/v2.173.2...v2.173.3) (2024-12-26) ### Bug Fixes