Skip to content
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

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

comcalvi
Copy link
Contributor

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

Add a feature flag which, when enabled, will generate a unique identifier from the token's value instead of a counter. This makes this logical ID no longer instantiation-order dependent.

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
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 1c25f5b
  • Result: FAILED
  • Build Logs (available for 30 days)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
2 participants