Module: Cumuliform::DSL::Functions::ConditionFunctions
- Included in:
- IntrinsicFunctions
- Defined in:
- lib/cumuliform/dsl/functions.rb
Overview
implements the intrinsic conditions functions
Instance Method Summary collapse
-
#and(condition_1, ..., condition_n) ⇒ Hash
Wraps Fn::And.
-
#equals(value, other_value) ⇒ Hash
Wraps Fn::Equals.
-
#if(condition, true_value, false_value) ⇒ Hash
Wraps Fn::If.
-
#not(condition) ⇒ Hash
Wraps Fn::Not.
-
#or(condition_1, ..., condition_n) ⇒ Hash
Wraps Fn::Or.
Instance Method Details
#and(condition_1, ..., condition_n) ⇒ Hash
Wraps Fn::And
Behaves as a logical AND operator for CloudFormation conditions. Arguments should be other conditions or things that will evaluate to true
or false
.
25 26 27 28 29 30 |
# File 'lib/cumuliform/dsl/functions.rb', line 25 def and(*conditions) unless (2..10).cover?(conditions.length) raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions" end {"Fn::And" => conditions} end |
#equals(value, other_value) ⇒ Hash
Wraps Fn::Equals
The arguments should be the literal values or refs you want to compare. Returns true or false when CloudFormation evaluates the template.
82 83 84 |
# File 'lib/cumuliform/dsl/functions.rb', line 82 def equals(value, other_value) {"Fn::Equals" => [value, other_value]} end |
#if(condition, true_value, false_value) ⇒ Hash
Wraps Fn::If
CloudFormation evaluates the Condition referred to the logical ID in the condition
arg and returns the true_value
if true
and false_value
otherwise. condition
cannot be an Fn::Ref
, but you can use our xref()
helper to ensure the logical ID is valid.
103 104 105 |
# File 'lib/cumuliform/dsl/functions.rb', line 103 def if(condition, true_value, false_value) {"Fn::If" => [condition, true_value, false_value]} end |
#not(condition) ⇒ Hash
Wraps Fn::Not
Behaves as a logical NOT operator for CloudFormation conditions. The argument should be another condition or something that will evaluate to true
or false
67 68 69 |
# File 'lib/cumuliform/dsl/functions.rb', line 67 def not(condition) {"Fn::Not" => [condition]} end |
#or(condition_1, ..., condition_n) ⇒ Hash
Wraps Fn::Or
Behaves as a logical OR operator for CloudFormation conditions. Arguments should be other conditions or things that will evaluate to true
or false
.
48 49 50 51 52 53 |
# File 'lib/cumuliform/dsl/functions.rb', line 48 def or(*conditions) unless (2..10).cover?(conditions.length) raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions" end {"Fn::Or" => conditions} end |