module CfnDsl::Functions

These functions are available anywhere inside a block for a JSONable object.

Constants

FN_SUB_SCANNER

Equivalent to the CloudFormation template built in function Fn::Sub

Public Instance Methods

FnAnd(array) click to toggle source

Equivalent to the CloudFormation template built in function Fn::And

# File lib/cfndsl/jsonable.rb, line 47
def FnAnd(array)
  raise 'The array passed to Fn::And must have at least 2 elements and no more than 10' if !array || array.count < 2 || array.count > 10

  Fn.new('And', array)
end
FnBase64(value) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Base64

# File lib/cfndsl/jsonable.rb, line 17
def FnBase64(value)
  Fn.new('Base64', value)
end
FnCidr(ipblock, count, sizemask) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Cidr

# File lib/cfndsl/jsonable.rb, line 108
def FnCidr(ipblock, count, sizemask)
  Fn.new('Cidr', [ipblock, count, sizemask])
end
FnEquals(value1, value2) click to toggle source

Equivalent to the Cloudformation template built in function Fn::Equals

# File lib/cfndsl/jsonable.rb, line 54
def FnEquals(value1, value2)
  Fn.new('Equals', [value1, value2])
end
FnFindInMap(map, key, value) click to toggle source

Equivalent to the CloudFormation template built in function Fn::FindInMap

# File lib/cfndsl/jsonable.rb, line 22
def FnFindInMap(map, key, value)
  Fn.new('FindInMap', [map, key, value])
end
FnGetAZs(region) click to toggle source

Equivalent to the CloudFormation template built in function Fn::GetAZs

# File lib/cfndsl/jsonable.rb, line 32
def FnGetAZs(region)
  Fn.new('GetAZs', region)
end
FnGetAtt(logical_resource, attribute) click to toggle source

Equivalent to the CloudFormation template built in function Fn::GetAtt

# File lib/cfndsl/jsonable.rb, line 27
def FnGetAtt(logical_resource, attribute)
  Fn.new('GetAtt', [logical_resource, attribute], [logical_resource])
end
FnIf(condition_name, true_value, false_value) click to toggle source

Equivalent to the Cloudformation template built in function Fn::If

# File lib/cfndsl/jsonable.rb, line 59
def FnIf(condition_name, true_value, false_value)
  Fn.new('If', [condition_name, true_value, false_value], [], [condition_name])
end
FnImportValue(value) click to toggle source

Equivalent to the CloudFormation template built in function Fn::ImportValue

# File lib/cfndsl/jsonable.rb, line 103
def FnImportValue(value)
  Fn.new('ImportValue', value)
end
FnJoin(string, array) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Join

# File lib/cfndsl/jsonable.rb, line 37
def FnJoin(string, array)
  Fn.new('Join', [string, array])
end
FnNot(value) click to toggle source

Equivalent to the Cloudformation template built in function Fn::Not

# File lib/cfndsl/jsonable.rb, line 64
def FnNot(value)
  if value.is_a?(Array)
    Fn.new('Not', value)
  else
    Fn.new('Not', [value])
  end
end
FnOr(array) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Or

# File lib/cfndsl/jsonable.rb, line 73
def FnOr(array)
  raise 'The array passed to Fn::Or must have at least 2 elements and no more than 10' if !array || array.count < 2 || array.count > 10

  Fn.new('Or', array)
end
FnSelect(index, array) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Select

# File lib/cfndsl/jsonable.rb, line 80
def FnSelect(index, array)
  Fn.new('Select', [index, array])
end
FnSplit(string, array) click to toggle source

Equivalent to the CloudFormation template built in function Fn::Split

# File lib/cfndsl/jsonable.rb, line 42
def FnSplit(string, array)
  Fn.new('Split', [string, array])
end
FnSub(string, substitutions = nil) click to toggle source
# File lib/cfndsl/jsonable.rb, line 87
def FnSub(string, substitutions = nil)
  raise ArgumentError, 'The first argument passed to Fn::Sub must be a string' unless string.is_a? String

  refs = string.scan(FN_SUB_SCANNER).map(&:first).map { |r| r.split('.', 2).first }

  if substitutions
    raise ArgumentError, 'The second argument passed to Fn::Sub must be a Hash' unless substitutions.is_a? Hash

    refs -= substitutions.keys.map(&:to_s)
    Fn.new('Sub', [string, substitutions], refs)
  else
    Fn.new('Sub', string, refs)
  end
end
Ref(value) click to toggle source

Equivalent to the CloudFormation template built in function Ref

# File lib/cfndsl/jsonable.rb, line 12
def Ref(value)
  RefDefinition.new(value)
end