Module: Pangea::Resources::Helpers

Defined in:
lib/pangea/resources/helpers.rb

Overview

Helper functions available in template context

Instance Method Summary collapse

Instance Method Details

#data_ref(data_type, data_name, attribute) ⇒ String

Create a data source reference

Parameters:

  • data_type (Symbol)

    The data source type

  • data_name (Symbol)

    The data source name

  • attribute (Symbol)

    The attribute to reference

Returns:

  • (String)

    Terraform data reference string



35
36
37
# File 'lib/pangea/resources/helpers.rb', line 35

def data_ref(data_type, data_name, attribute)
  "${data.#{data_type}.#{data_name}.#{attribute}}"
end

#local(local_name) ⇒ String

Create a local value reference

Parameters:

  • local_name (Symbol)

    The local value name

Returns:

  • (String)

    Terraform local reference string



49
50
51
# File 'lib/pangea/resources/helpers.rb', line 49

def local(local_name)
  "${local.#{local_name}}"
end

#ref(resource_type, resource_name, attribute) ⇒ String

Create a terraform reference to another resource

Parameters:

  • resource_type (Symbol)

    The resource type (e.g., :aws_vpc)

  • resource_name (Symbol)

    The resource name

  • attribute (Symbol)

    The attribute to reference (e.g., :id)

Returns:

  • (String)

    Terraform reference string



26
27
28
# File 'lib/pangea/resources/helpers.rb', line 26

def ref(resource_type, resource_name, attribute)
  "${#{resource_type}.#{resource_name}.#{attribute}}"
end

#var(var_name) ⇒ String

Create a variable reference

Parameters:

  • var_name (Symbol)

    The variable name

Returns:

  • (String)

    Terraform variable reference string



42
43
44
# File 'lib/pangea/resources/helpers.rb', line 42

def var(var_name)
  "${var.#{var_name}}"
end