-
Notifications
You must be signed in to change notification settings - Fork 97
fix: cdk import fails with "modified resources ... not being imported" when a stack has unordered dependencies
#1602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+8
−8
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
49ee0e7
Clone templates for safe normalization
saeekailas f6314a6
fix(toolkit-lib): deep clone cached template in ResourceImporter
saeekailas f33f80a
Merge branch 'main' into main
saeekailas 9e626e9
Replace deep copy with structuredClone for templates
saeekailas 5741ac0
Use structuredClone for currentTemplate method
saeekailas 4a7486e
Replace JSON.parse with structuredClone for template
saeekailas c7db841
Merge branch 'main' into main
saeekailas 60d879a
Update dependabot.yml
saeekailas 1439d61
Update SelfMutationOnForks.ts
saeekailas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,27 +296,23 @@ export class ResourceImporter { | |
| */ | ||
| private async currentTemplate(): Promise<any> { | ||
| if (!this._currentTemplate) { | ||
| this._currentTemplate = await this.cfn.readCurrentTemplate(this.stack); | ||
| this._currentTemplate = Object.freeze(structuredClone(await this.cfn.readCurrentTemplate(this.stack))); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to clone this? |
||
| } | ||
| return this._currentTemplate; | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please don't remove unrelated other lines, especially if it's formatting |
||
| /** | ||
| * Return the current template, with the given resources added to it | ||
| */ | ||
| private async currentTemplateWithAdditions(additions: ImportableResource[]): Promise<any> { | ||
| const template = await this.currentTemplate(); | ||
| const template = structuredClone(await this.currentTemplate()); | ||
| if (!template.Resources) { | ||
| template.Resources = {}; | ||
| } | ||
|
|
||
| for (const add of additions) { | ||
| template.Resources[add.logicalId] = add.resourceDefinition; | ||
| } | ||
|
|
||
| return template; | ||
| } | ||
|
|
||
| /** | ||
| * Get a list of import identifiers for all resource types used in the given | ||
| * template that do support the import operation (SINGLETON) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use our automated formatting