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): top-level resources cannot use long logical ids #6419

Merged
merged 3 commits into from
Feb 24, 2020

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Feb 24, 2020

When allocating a logical ID for a CloudFormation resource we normally render the id by taking in the full construct path, trim it down to 240 characters and append a hash to it to make sure its unique. This technically allows construct IDs to be of any length.

However, when a resource is defined as a top-level resource (i.e. the child of a stack), it won't get this treatment and we will just use the construct id as it's logical id.

In this case, synthesis will fail with an error indicating the logical ID is invalid (too long).

This might work ok if the logical ID is human provided, but in some cases (like #6190), the id is actually created automatically and in some cases can be longer than 255.

This fix will only apply the special treatment to top-level resources if their construct ID is shorter than the maximum allowed length (255). Otherwise, it will use the same mechanism to trim them and append the hash.

Fixes #6190.


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

When allocating a logical ID for a CloudFormation resource we normally render the id by taking in the full construct path, trim it down to 240 characters and append a hash to it to make sure its unique. This technically allows construct IDs to be of any length.

However, when a resource is defined as a top-level resource (i.e. the child of a stack), it won't get this treatment and we will just use the construct id as it's logical id.

In this case, synthesis will fail with an error indicating the logical ID is invalid (too long).

This might work ok if the logical ID is human provided, but in some cases (like #6190), the id is actually created automatically and in some cases can be longer than 255.

This fix will only apply the special treatment to top-level resources if their construct ID is shorter than the maximum allowed length (255). Otherwise, it will use the same mechanism to trim them and append the hash.

Fixes #6190.
@eladb eladb self-assigned this Feb 24, 2020
@eladb eladb requested a review from a team February 24, 2020 14:47
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 24, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c384157
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: d18f105
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@eladb eladb requested a review from rix0rrr February 24, 2020 16:51
@mergify
Copy link
Contributor

mergify bot commented Feb 24, 2020

Thank you for contributing! Your pull request is now being automatically merged.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f5f27c5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Feb 24, 2020

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit 2a418b9 into master Feb 24, 2020
@mergify mergify bot deleted the benisrae/fix-long-logical-id branch February 24, 2020 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logical ID must adhere to the regular expression: /^[A-Za-z][A-Za-z0-9]{1,254}$/, got -----------
3 participants