Skip to content

Commit

Permalink
Implement requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Gama committed Jun 11, 2024
1 parent 76a5c3e commit 21f7935
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/aws-cdk-lib/aws-cloudfront/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ export class Function extends Resource implements IFunction {
}

private generateName(): string {
const maxNameLength = 64 - '${Token[AWS.Region.00]}'.length;
if (Names.uniqueId(this).length < maxNameLength) {
/**
* Since token string can be single- or double-digit region name, it may
* lead to non-deterministic behaviour.
*/
const idLength = 64 - '${Token[AWS.Region.00]}'.length;
if (Names.uniqueId(this).length <= idLength) {
return Stack.of(this).region + Names.uniqueId(this);
}
return Stack.of(this).region + Lazy.string({
Expand Down

0 comments on commit 21f7935

Please sign in to comment.