Class: Terraspace::Terraform::RemoteState::Marker::Output

Inherits:
Object
  • Object
show all
Extended by:
Memoist, Compiler::DirsConcern
Includes:
Util::Logging
Defined in:
lib/terraspace/terraform/remote_state/marker/output.rb

Instance Method Summary collapse

Methods included from Compiler::DirsConcern

cache_dirs, dirs, extract_stack_name, local_paths, mod_names, select_stack?, stack_names, with_each_mod

Methods included from Util::Logging

#logger

Constructor Details

#initialize(mod, identifier, options = {}) ⇒ Output

Returns a new instance of Output.



5
6
7
8
9
# File 'lib/terraspace/terraform/remote_state/marker/output.rb', line 5

def initialize(mod, identifier, options={})
  @mod, @identifier, @options = mod, identifier, options
  @parent_name = @mod.name
  @child_name, @output_key = @identifier.split('.')
end

Instance Method Details

#buildObject

Returns OutputProxy



12
13
14
15
16
17
18
19
20
21
# File 'lib/terraspace/terraform/remote_state/marker/output.rb', line 12

def build
  if valid?
    Terraspace::Dependency::Registry.register(@parent_name, @child_name)
  else
    warning
  end
  # MARKER for debugging. Only appears on 1st pass. Will not see unless changing Terraspace code for debugging.
  marker = "MARKER:terraform_output('#{@identifier}')"
  Terraspace::Terraform::RemoteState::OutputProxy.new(@mod, marker, @options)
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/terraspace/terraform/remote_state/marker/output.rb', line 23

def valid?
  self.class.stack_names.include?(@child_name)
end

#warningObject



27
28
29
30
31
32
33
# File 'lib/terraspace/terraform/remote_state/marker/output.rb', line 27

def warning
  logger.warn "WARN: The #{@child_name} stack does not exist or is configured to be not included. IE: config.all.include_stacks or config.all.exclude_stacks".color(:yellow)
  caller_line = caller.find { |l| l.include?('.tfvars') }
  return unless caller_line # specs dont have a tfvars file
  source_code = PrettyTracer.new(caller_line).source_code
  logger.info source_code
end