Skip to content

refactoring of removal of AWS::NoValue in reference list for CFn #12288

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,18 @@ def _resolve_refs_recursively(
join_values,
)

join_values = [
resolve_refs_recursively(
account_id,
region_name,
stack_name,
resources,
mappings,
conditions,
parameters,
v,
)
for v in join_values
]
# resolve reference in the items list
assert isinstance(join_values, list)
join_values = resolve_refs_recursively(
account_id,
region_name,
stack_name,
resources,
mappings,
conditions,
parameters,
join_values,
)

none_values = [v for v in join_values if v is None]
if none_values:
Expand All @@ -420,9 +419,7 @@ def _resolve_refs_recursively(
raise Exception(
f"Cannot resolve CF Fn::Join {value} due to null values: {join_values}"
)
return value[keys_list[0]][0].join(
[str(v) for v in join_values if v != "__aws_no_value__"]
)
return value[keys_list[0]][0].join([str(v) for v in join_values])

if stripped_fn_lower == "sub":
item_to_sub = value[keys_list[0]]
Expand Down Expand Up @@ -756,17 +753,22 @@ def _resolve_refs_recursively(
{inner_list[0]: inner_list[1]},
)

for i in range(len(value)):
value[i] = resolve_refs_recursively(
# remove _aws_no_value_ from resulting references
clean_list = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for writing the longer (but easier to understand) loop manually building up a new list, rather than some horribly complex list comprehension!

for item in value:
temp_value = resolve_refs_recursively(
account_id,
region_name,
stack_name,
resources,
mappings,
conditions,
parameters,
value[i],
item,
)
if not (isinstance(temp_value, str) and temp_value == PLACEHOLDER_AWS_NO_VALUE):
clean_list.append(temp_value)
value = clean_list

return value

Expand Down
Loading