Module: Skywriter::Function

Defined in:
lib/skywriter/function.rb

Class Method Summary collapse

Class Method Details

.and(*conditions) ⇒ Hash

Intrinsic conditional function Fn::And

Parameters:

  • *conditions

    Conditions that evaluate to true or false.

Returns:

  • (Hash)

    A hash describing the conditional function



86
87
88
# File 'lib/skywriter/function.rb', line 86

def self.and(*conditions)
  { "Fn::And" => conditions }
end

.base64(value) ⇒ Hash

Intrinsic function Fn::Base64

Parameters:

  • value

    The string value you want to convert to Base64.

Returns:

  • (Hash)

    A hash describing the function



19
20
21
# File 'lib/skywriter/function.rb', line 19

def self.base64(value)
  { "Fn::Base64" => value }
end

.equals(left, right) ⇒ Hash

Intrinsic conditional function Fn::Equals

Parameters:

  • left

    A value of any type that you want to compare.

  • right

    A value of any type that you want to compare.

Returns:

  • (Hash)

    A hash describing the conditional function



97
98
99
# File 'lib/skywriter/function.rb', line 97

def self.equals(left, right)
  { "Fn::Equals" => [left, right] }
end

.find_in_map(map, *keys) ⇒ Hash

Intrinsic function Fn::FindInMap

Parameters:

  • map

    The logical name of a mapping declared in the Mappings section that contains the keys and values.

  • *keys

    A list describing the n-th level keys to index

Returns:

  • (Hash)

    A hash describing the function



30
31
32
# File 'lib/skywriter/function.rb', line 30

def self.find_in_map(map, *keys)
  { "Fn::FindInMap" => Array(map) + keys }
end

.get_att(resource_name, attribute_name) ⇒ Hash

Intrinsic function Fn::GetAtt

Parameters:

  • resource_name

    The logical name of the resource that contains the attribute you want.

  • attribute_name

    The name of the resource-specific attribute whose value you want.

Returns:

  • (Hash)

    A hash describing the function



41
42
43
# File 'lib/skywriter/function.rb', line 41

def self.get_att(resource_name, attribute_name)
  { "Fn::GetAtt" => [resource_name, attribute_name] }
end

.get_azs(region = nil) ⇒ Hash

Intrinsic function Fn::GetAZs

Parameters:

  • region (defaults to: nil)

    The name of the region for which you want to get the Availability Zones.

Returns:

  • (Hash)

    A hash describing the function



51
52
53
# File 'lib/skywriter/function.rb', line 51

def self.get_azs(region = nil)
  { "Fn::GetAZs" => region.to_s }
end

.if(condition, when_true, when_false) ⇒ Hash

Intrinsic conditional function Fn::If

Parameters:

  • condition

    A reference to a condition in the Conditions section

  • when_true

    A value to be returned if the specified condition evaluates to true

  • when_false

    A value to be returned if the specified condition evaluates to false

Returns:

  • (Hash)

    A hash describing the conditional function



109
110
111
# File 'lib/skywriter/function.rb', line 109

def self.if(condition, when_true, when_false)
  { "Fn::If" => [condition, when_true, when_false] }
end

.join(sep, *values) ⇒ Hash

Intrinsic function Fn::Join

Parameters:

  • sep

    The value you want to occur between values

  • *values

    The values you wish to join

Returns:

  • (Hash)

    A hash describing the function



62
63
64
# File 'lib/skywriter/function.rb', line 62

def self.join(sep, *values)
  { "Fn::Join" => [sep.to_s, values] }
end

.not(condition) ⇒ Hash

Intrinsic conditional function Fn::Not

Parameters:

  • condition

    A condition such as Fn::Equals that evaluates to true or false

Returns:

  • (Hash)

    A hash describing the conditional function



119
120
121
# File 'lib/skywriter/function.rb', line 119

def self.not(condition)
  { "Fn::Not" => [condition] }
end

.or(*conditions) ⇒ Hash

Intrinsic conditional function Fn::Or

Parameters:

  • *conditions

    Conditions that evaluate to true or false

Returns:

  • (Hash)

    A hash describing the conditional function



129
130
131
# File 'lib/skywriter/function.rb', line 129

def self.or(*conditions)
  { "Fn::Or" => conditions }
end

.ref(logical_name) ⇒ Hash

Intrinstic function ‘Ref’

Parameters:

  • logical_name

    The logical name of the resource or parameter you want to dereference

Returns:

  • (Hash)

    A hash describing the function



9
10
11
# File 'lib/skywriter/function.rb', line 9

def self.ref(logical_name)
  { "Ref" => logical_name }
end

.select(index, *values) ⇒ Hash

Intrinsic function Fn::Select

Parameters:

  • index

    The index of the object to retrieve, zero-indexed

  • *values

    The list of objects to select from

Returns:

  • (Hash)

    A hash describing the function



73
74
75
# File 'lib/skywriter/function.rb', line 73

def self.select(index, *values)
  { "Fn::Select" => [index.to_s, values] }
end