Skip to content

Commit

Permalink
Fix issue with conditional outputs
Browse files Browse the repository at this point in the history
The conditional outputs were not being correctly evaluated. This is
just a patch, I left comments about a better way to fix conditions in
the future.
  • Loading branch information
Levi Blaney committed Jun 1, 2023
1 parent 9f7c2f3 commit bd79459
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cloud_radar/cf/unit/_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,12 @@ def resolve_values(

# Takes care of the tricky 'Condition' key
if key == "Condition":
# This takes care of conditional resources
if "Properties" in data:
# data[key] = functions.condition(self, value)
# The real fix is to not resolve every key/value in the entire
# cloudformation template. We should only attempt to resolve what is needed,
# like outputs and resource properties.
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

if "Properties" in data or "Value" in data:
continue

# If it's an intrinsic func
Expand Down
1 change: 1 addition & 0 deletions tests/templates/log_bucket/log_bucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Resources:

Outputs:
LogsBucketName:
Condition: AlwaysTrue
Description: Name of the logs bucket.
Value: !If [RetainBucket, !Ref RetainLogsBucket, !Ref LogsBucket]
Export:
Expand Down

0 comments on commit bd79459

Please sign in to comment.