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

Logical resource naming within the template #57

Open
reidca opened this issue Feb 12, 2020 · 8 comments
Open

Logical resource naming within the template #57

reidca opened this issue Feb 12, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@reidca
Copy link

reidca commented Feb 12, 2020

I created a template for our VPC using Former2.

I added all related resources I could think of as well as those suggested by Former2.

This resulted in a large template, over 500 lines long and a lot of resources.

Because all the resources have random logical names it can make identifying them difficult when looking at the template. Although I understand that you could not possibly infer the logical name with anything meaningful, I think it would be useful to put the type of the resource somewhere in the name to at least give some semantic meaning to the resources.

e..g. instead of a resource being called ec26de3980, call it VPCGatewayAttachmentec26de3980

This would help human comprehension of the template, especially when looking at what REF and GetAtt are referring to.

Thanks!

@iann0036
Copy link
Owner

iann0036 commented Feb 13, 2020

Thanks for the suggestion @reidca!

I've thought previously about some better naming for these resources, perhaps by using some of the primary identifiers returned from !Ref for example. I've also considered a custom templating solution where you could pick your own pattern that suits you.

The resource name is indeed probably more appropriate and it's what CDK uses, though I do find that slightly long (they also discuss this same issue).

Give me some time to consider good alternatives 🤔

@reidca
Copy link
Author

reidca commented Feb 13, 2020

Agreed it does lead to long names but I think on the whole this is preferable to a resource with no inferable meaning as it currently stands. Thanks.

@reidca
Copy link
Author

reidca commented Feb 13, 2020

I have just completed my first "Import" of my manually modified template. On the dialog where it asks you for the ids of the resources to import I am not sure how it would have been possible for me to input the correct ids without me having renamed the logical ids prior to this.

e.g. for subnets. I name them something like SubnetAPrivate which gives some semantic meaning to the resource and then when fetching the id I can look in the console for the Private subnet in AZ A. If the name was just a hash it would have required more lookups.

I know this is not easy to achieve and the naming may in some cases depend on the type of resource being generated such as in this case. given the number of resource types this would be difficult to achieve.

Happy to help play around with ideas or test.

@iann0036
Copy link
Owner

Would a setting/preference suffice? There's probably a few strategies that could be implemented here:

Screen Shot 2020-02-13 at 10 01 10 pm

@reidca
Copy link
Author

reidca commented Feb 13, 2020

I think that would be very useful. If there is a way of adding overrides through the UI that would also be great although I appreciate that may present a challenge!

@iann0036
Copy link
Owner

Hey @reidca,

Just got the new logical ID naming strategies in (58cb9b2).

Give it a shot and let me know what you think!

@iann0036 iann0036 added the enhancement New feature or request label Feb 18, 2020
@hodgsonsam
Copy link

Hi Ian, firstly amazing work this is an awesome tool :)

Is it possible to use the Name tag as the logical ID in the generated template?

Or, for the benefit of those downloading the template and importing manually the resourceID as the logicalID suffix? This would make it easy to copy paste the resourceID's on the Import page in Cloudformation. NameTag-ResourceID might be ideal.

@iann0036
Copy link
Owner

iann0036 commented Dec 9, 2020

Hey @hodgsonsam,

Thanks for the suggestion!

I think a new naming strategy based on the "Name" tag, where available, would be great. Happy to put this on the roadmap.

On importing, many resources do need more than one property value to properly identify the resource, so this may not be a foolproof strategy. There is an import feature available straight from the CloudFormation outputs screen that manages the change set creation (and optionally, deployment) process for you.

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

No branches or pull requests

3 participants