Skip to content

fix(core): apps that use token-aware-stringify are construct-instantiation-order-dependent#31470

Merged
mergify[bot] merged 27 commits intomainfrom
comcalvi/order-dependent-logical-IDs
Oct 1, 2024
Merged

fix(core): apps that use token-aware-stringify are construct-instantiation-order-dependent#31470
mergify[bot] merged 27 commits intomainfrom
comcalvi/order-dependent-logical-IDs

Conversation

@comcalvi
Copy link
Copy Markdown
Contributor

@comcalvi comcalvi commented Sep 17, 2024

Issue # (if applicable)

Closes #31345.

Reason for this change

Any stringified value containing an intrinsic will use a custom resource to resolve this value at deploy time.

Today, this custom resource's logical ID will take the form 'CDKJsonStringify<number>',
where is a counter incremented for each stringified value. This results in resource replacement updates for the custom resource when the order of construct instantiation is changed, like changing this:

const app = new App();
new SomeStack(app, 'Stack1');
new SomeStack(app, 'Stack2');

to:

const app = new App();
new SomeStack(app, 'Stack2');
new SomeStack(app, 'Stack1');

This only happens if SomeStack stringifies a token, which some CDK constructs will do automatically. These resource replacements won't affect customer infrastructure, but customers using a common setup as in #31345 will see diffs on the same application in different environments, which violates the repeatability promise of CDK.

Description of changes

Generate a unique identifier from the token's value instead of a counter. This makes this logical ID no longer instantiation-order dependent.

This will cause diffs when upgrading.

Description of how you validated changes

Unit, integration, and manual tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team September 17, 2024 19:39
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Sep 17, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 17, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 20, 2024
@comcalvi comcalvi added the pr/do-not-merge This PR should not be merged at this time. label Sep 27, 2024
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 27, 2024
@comcalvi comcalvi removed the pr/do-not-merge This PR should not be merged at this time. label Oct 1, 2024
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 1, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 92c9551
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 4128bf1 into main Oct 1, 2024
@mergify mergify bot deleted the comcalvi/order-dependent-logical-IDs branch October 1, 2024 01:02
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 1, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(Core): unexpected logical id change for CdkJsonStringify when order of stack changed

3 participants