-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat: New Command Simplify
to Modify Templates to Use Fn::ForEach
#185
Conversation
Modify to foreach
Merge from Main
Issue: - "Ref: " would be included in the Ref were the Identifier in Fn::ForEach would be called
Fixed Ref issue
Modify to foreach
Clean up comments
Clean up for loops
Fixed rain help test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would be better as an addition to the fmt
command, instead of adding a new top level command. rain fmt --foreach
is more specific than rain simplify
. Unless we had some more ideas for ways that we could simplify templates (fmt
already converts intrinsics to short form, which is a minor simplification).
Can you point me to the code that figures out what resources have been duplicated? I was finding it a little hard to follow the flow of the code from the top down, maybe you could add a comment section somewhere that describes the overall design of the feature.
I noticed a few code blocks that look like they were copied from other areas in the project, it would be good if we could refactor/reuse rather than copy, for example simplify.String
.
Description of changes:
This new command can modify templates to use the new Fn::ForEach function. Right now it can modify basic templates with only one property that is different in Resources/Outputs/Conditions.
How to use:
rain simplify --foreach ../path/to/template.yaml
An example of a template that can be modified is shown below.
Unprocessed template:
Processed template:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.