Module: Cumuliform::DSL::Functions

Included in:
Template
Defined in:
lib/cumuliform/dsl/functions.rb

Overview

DSL methods for working with CloudFormation Intrinsic and Ref functions

Defined Under Namespace

Modules: ConditionFunctions Classes: IntrinsicFunctions

Instance Method Summary collapse

Instance Method Details

#fnIntrinsicFunctions

returns an instance of IntrinsicFunctions which provides wrappers for Fn::* functions

Returns:



333
334
335
# File 'lib/cumuliform/dsl/functions.rb', line 333

def fn
  @fn ||= IntrinsicFunctions.new(self)
end

#ref(logical_id) ⇒ Hash

Wraps Ref

CloudFormation evaluates the Ref and returns the value of the Parameter or Resource with Logical ID logical_id.

Parameters:

  • logical_id (String)

    The logical ID of the parameter or resource

Returns:

  • (Hash)

    the Ref object



326
327
328
# File 'lib/cumuliform/dsl/functions.rb', line 326

def ref(logical_id)
  {"Ref" => xref(logical_id)}
end

#xref(logical_id) ⇒ String

Checks logical_id is present and either returns logical_id or raises Cumuliform::Error::NoSuchLogicalId.

You can use it anywhere you need a string Logical ID and want the protection of having it be verified, for example in the cfn-init invocation in a Cfn::Init metadata block or the condition name field of, e.g. Fn::And.

Parameters:

  • logical_id (String)

    the logical ID you want to check

Returns:

  • (String)

    the logical_id param



312
313
314
315
316
317
# File 'lib/cumuliform/dsl/functions.rb', line 312

def xref(logical_id)
  unless has_logical_id?(logical_id)
    raise Error::NoSuchLogicalId, logical_id
  end
  logical_id
end