module Cumuliform::DSL::Functions::ConditionFunctions

implements the intrinsic conditions functions

Public Instance Methods

and(*conditions) click to toggle source

Wraps Fn::And

see docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86066

Behaves as a logical AND operator for CloudFormation conditions. Arguments should be other conditions or things that will evaluate to true or false.

@overload and(condition_1, …, condition_n)

@param condition_1 [Hash<boolean-returning ref, intrinsic function,
  or condition>] Condition / value to be ANDed
@param condition_n [Hash<boolean-returning ref, intrinsic function,
  or condition>] Condition / value to be ANDed (min 2, max 10
  condition args)

@return [Hash] the Fn::And object

# 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) click to toggle source

Wraps Fn::Equals

see docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86148

The arguments should be the literal values or refs you want to compare. Returns true or false when CloudFormation evaluates the template.

@param value [String, Hash<value-returning ref>] @param other_value [String, Hash<value-returning ref>] @return [Hash] the Fn::Equals object

# 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) click to toggle source

Wraps Fn::If

see docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86223

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.

@param condition the Logical ID of the Condition to be

checked

@param true_value the value to be returned if condition

evaluates true

@param false_value the value to be returned if condition

evaluates false

@return [Hash] the Fn::If object

# 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) click to toggle source

Wraps Fn::Not

see docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86402

Behaves as a logical NOT operator for CloudFormation conditions. The argument should be another condition or something that will evaluate to true or false

@param condition [Hash<boolean-returning ref, intrinsic function, or

condition>] Condition / value to be NOTed

@return [Hash] the Fn::Not object

# File lib/cumuliform/dsl/functions.rb, line 67
def not(condition)
  {"Fn::Not" => [condition]}
end
or(*conditions) click to toggle source

Wraps Fn::Or

see docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86490

Behaves as a logical OR operator for CloudFormation conditions. Arguments should be other conditions or things that will evaluate to true or false.

@overload or(condition_1, …, condition_n)

@param condition_1 [Hash<boolean-returning ref, intrinsic function,
  or condition>] Condition / value to be ORed
@param condition_n [Hash<boolean-returning ref, intrinsic function,
  or condition>] Condition / value to be ORed (min 2, max 10
  condition args)

@return [Hash] the Fn::Or object

# 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