Class: TerraformWrapper::Tasks::Taint

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Shared::Logging
Defined in:
lib/terraform-wrapper/tasks/taint.rb

Instance Method Summary collapse

Methods included from Shared::Logging

configure_logger_for, logger_for

Constructor Details

#initialize(binary:, code:, options:) {|_self| ... } ⇒ Taint

Returns a new instance of Taint.

Yields:

  • (_self)

Yield Parameters:



22
23
24
25
26
27
28
29
30
# File 'lib/terraform-wrapper/tasks/taint.rb', line 22

def initialize(binary:, code:, options:)
  @binary  = binary
  @code    = code
  @options = options

  yield self if block_given?

  taint_task
end

Instance Method Details

#taint_taskObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/terraform-wrapper/tasks/taint.rb', line 34

def taint_task
  desc 'Taint a piece of existing infrastructure so that Terraform recreates it at next apply.'
  task :taint, %i[config address] => :binary do |_t, args|
    options = @options.merge({ 'name' => args[:config] })

    logger.info('Processing configuration for Terraform taint...')

    config = TerraformWrapper::Shared::Config.new(code: @code, options: options)
    runner = TerraformWrapper::Shared::Runner.new(binary: @binary, code: @code)

    logger.info("Running Terraform taint for service: #{config.service}, component: #{@code.name}...")

    runner.init(config: config)
    runner.taint(address: args[:address])
  end
end