Reputation: 3146
I have conditions
Red: !Equals [!Ref Color,Red]
Blue: !Equals [!Ref Color,Blue]
Green: !Equals [!Ref Color,Green]
Orange: !Equals [!Ref Color,Orange]
At the moment, I am using an If statement with 2 conditions. Properties: Name: !If [Red,!Sub 'I choose Red','I choose Blue']
How can I have the name attribute with multiple if clause to represend all of them?
Like this
If Red
"Red"
else if "Blue"
"Blue"
else if "Green"
"Green"
etc..
Upvotes: 0
Views: 4045
Reputation: 8562
You can achieve this via nested If
functions, i.e. the "else" value resolves to the value of another If
function:
!If
- Red
- "Red"
- !If
- Blue
- "Blue"
- !If
- Green
- "Green"
- !Ref AWS::NoValue # if none of the above conditions match
(I'm not 100% sure the shorthand !If
syntax will work nested like that but I suspect it will. Otherwise just change it to the longhand Fn::If:
.)
Upvotes: 2