Skip to content

Instantly share code, notes, and snippets.

@benbridts
Created June 16, 2020 08:55
Show Gist options
  • Select an option

  • Save benbridts/5681541aa43a673267db1aaa6b3d1b82 to your computer and use it in GitHub Desktop.

Select an option

Save benbridts/5681541aa43a673267db1aaa6b3d1b82 to your computer and use it in GitHub Desktop.
CloudFormation template only outputting the not empty parameters
---
Parameters:
Parameter01:
Type: String
Default: ''
Parameter02:
Type: String
Default: ''
Parameter03:
Type: String
Default: ''
Conditions:
NotP01: !Equals [!Ref Parameter01, '']
NotP02: !Equals [!Ref Parameter02, '']
NotP03: !Equals [!Ref Parameter03, '']
Outputs:
NotEmptyParameters:
Description: Only outputs the parameters that are not empty
Value:
!Join
- ', '
-
- !If [NotP01, !Ref "AWS::NoValue", !Sub "Parameter01=${Parameter01}"]
- !If [NotP02, !Ref "AWS::NoValue", !Sub "Parameter02=${Parameter02}"]
- !If [NotP03, !Ref "AWS::NoValue", !Sub "Parameter03=${Parameter03}"]
Resources:
Dummy:
Type: AWS::CloudFormation::WaitConditionHandle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment