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: ensure all generated logical ids conform to CloudFormation standard #396

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

jacobwinch
Copy link
Contributor

@jacobwinch jacobwinch commented Apr 8, 2021

What does this change?

This PR ensures that the logical ids generated by this library always conform to AWS's standard:

The logical ID must be alphanumeric (A-Za-z0-9).

Does this change require changes to existing projects or CDK CLI?

No.

How to test

Existing unit tests have been updated due to this change.

How can we measure success?

Previously, it was impossible to CloudForm the resources created by the GuInstanceRole construct if your AppIdentity included non-alphanumeric characters (e.g. when using test-app). After this change, users will be able to include hyphens (or other non-alphanumeric characters if they really must?!) in their app names.

Have we considered potential risks?

I can't think of any risks which would result from making this change.

@jacobwinch jacobwinch requested a review from a team April 8, 2021 08:23
@@ -15,7 +15,9 @@ export interface Identity extends StackStageIdentity, AppIdentity {}
export const AppIdentity = {
suffixText(appIdentity: AppIdentity, text: string): string {
const titleCaseApp = appIdentity.app.charAt(0).toUpperCase() + appIdentity.app.slice(1);
return `${text}${titleCaseApp}`;
// CloudFormation Logical Ids must be alphanumeric, so remove any non-alphanumeric characters: https://stackoverflow.com/a/20864946
const alphanumericTitleCaseApp = titleCaseApp.replace(/[\W_]+/g, "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! This is a lot cleaner than my ascii code array idea!

@jacobwinch jacobwinch merged commit 01e271b into main Apr 8, 2021
@jacobwinch jacobwinch deleted the jw-conform-to-cfn-logical-id-format branch April 8, 2021 08:31
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

🎉 This PR is included in version 7.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants