Skip to content

Conversation

markpeek
Copy link
Member

The template generator would introduce a list wrapping for AWS Functions (Cidr, GetAZs, Split) that return a list resulting in the function results wrapped in a list. This detects and corrects that behavior.

@ilons I expanded the scope of your patch to include other functions and added a test. Could you review, test, and approve?

Fixes #2162

The template generator would introduce a list wrapping for AWS
Functions (Cidr, GetAZs, Split) that return a list resulting in
the function results wrapped in a list. This detects and corrects
that behavior.
@ilons
Copy link

ilons commented Sep 24, 2025

As far as I can judge, this does what is expected. Due to lack of familiarity with the code-base however, I'm unsure if it has any unwanted side-effects in areas I'm not aware of.

)
from troposphere.policies import CreationPolicy, UpdatePolicy

AWS_LIST_RETURN_FUNCTIONS = (Cidr, GetAZs, Split)
Copy link

Choose a reason for hiding this comment

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

Might be a bit philosophical, but should we prevent any function that have the potential of returning a list from being wrapped?

For example, the following ones have the potential of returning a list:

  • FindInMap
  • GetAtt
  • Select

However, I think the current approach is a good start, as it prevents wrapping of functions which we are certain to return a list in all use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the review. Since it is targeted it should not cause regressions and the tests do run over all the examples so I think we're good there as well. I'm going to commit this now.

@markpeek markpeek merged commit 10338bd into main Sep 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TemplateGenerator: Cloudformation split function call wrapped inside list

2 participants