Class: TerraformConfig::LocalVariable

Inherits:
Base
  • Object
show all
Defined in:
lib/core/terraform_config/local_variable.rb

Constant Summary collapse

VARIABLE_NAME_REGEX =
/\A[a-zA-Z][a-zA-Z0-9_]*\z/.freeze

Constants included from Dsl

Dsl::EXPRESSION_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#importable?, #locals, #reference

Methods included from Dsl

#argument, #block

Constructor Details

#initialize(**variables) ⇒ LocalVariable

Returns a new instance of LocalVariable.



9
10
11
12
13
14
# File 'lib/core/terraform_config/local_variable.rb', line 9

def initialize(**variables)
  super()

  @variables = variables
  validate_variables!
end

Instance Attribute Details

#variablesObject (readonly)

Returns the value of attribute variables.



7
8
9
# File 'lib/core/terraform_config/local_variable.rb', line 7

def variables
  @variables
end

Instance Method Details

#to_tfObject



16
17
18
19
20
21
22
# File 'lib/core/terraform_config/local_variable.rb', line 16

def to_tf
  block :locals do
    variables.each do |var, value|
      argument var, value
    end
  end
end