-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
(cloudfront): Function name is created non-deterministically #28629
Comments
Yes I guess we should use |
Actually making that change should be pretty trivial and non-disruptive; apparently function name resources require no interruption for updates. I'll work on the PR. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-function.html#cfn-cloudfront-function-name Edit: Just kidding... the CloudFormation docs are wrong. aws-cloudformation/cloudformation-coverage-roadmap#1893 has been opened to report the documentation issue. |
### Issue # (if applicable) Closes #20017 as well as #15523 and #28629 ### Reason for this change Due to the way function names are generated using token strings with either single- or double-digit numbers, longer function names can be truncated differently, leading to inconsistency in generated CloudFormation templates. ### Description of changes To ensure backwards compatibility, if names are longer than 64 characters and use region tokens, if the token uses a single-digit region number, it takes the first **31** characters + the last 32 characters; if the token uses a double-digit region number or otherwise, it takes the first **32** characters + the last 32 characters. This ensures it will always take the same first chunk of the actual function's name. ### Description of how you validated changes A new unit test was added to verify the consistency of function names in the template. ### 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*
|
### Issue # (if applicable) Closes aws#20017 as well as aws#15523 and aws#28629 ### Reason for this change Due to the way function names are generated using token strings with either single- or double-digit numbers, longer function names can be truncated differently, leading to inconsistency in generated CloudFormation templates. ### Description of changes To ensure backwards compatibility, if names are longer than 64 characters and use region tokens, if the token uses a single-digit region number, it takes the first **31** characters + the last 32 characters; if the token uses a double-digit region number or otherwise, it takes the first **32** characters + the last 32 characters. This ensures it will always take the same first chunk of the actual function's name. ### Description of how you validated changes A new unit test was added to verify the consistency of function names in the template. ### 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*
Describe the bug
Creating a CloudFront Function without specifying
name
can result in non-deterministic naming when theNode
ID is relatively long. This results in unexpected function renames.Expected Behavior
The method used to create a CloudFront Function name should be deterministic, predicable, and stable.
Current Behavior
The name of Functions is unstable, resulting in resource renames and snapshot failures.
Reproduction Steps
Run the following sample integration test several times. See that eventually it bounces between:
AReallyLonIdIsAlsoPrettyLongIGuess25040025
AReallyLoIdIsAlsoPrettyLongIGuess25040025
for the name of the function.
Possible Solution
aws-cdk/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts
Lines 198 to 205 in 3656a4c
Names.uniqueResourceName
should probably be used instead.Additional Information/Context
This is also causing the failure on #28571
CDK CLI Version
2.118.0
Framework Version
2.118.0
Node.js Version
v20.2.0
OS
Linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: