class TerraformWrapper::Tasks::PlanDestroy

Public Class Methods

new(binary:, code:, options:) { |self| ... } click to toggle source
# File lib/terraform-wrapper/tasks/plandestroy.rb, line 25
def initialize(binary:, code:, options:)
  @binary  = binary
  @code    = code
  @options = options

  yield self if block_given?

  plan_destroy_task
end

Public Instance Methods

plan_destroy_task() click to toggle source
# File lib/terraform-wrapper/tasks/plandestroy.rb, line 37
def plan_destroy_task
  desc "Creates a Terraform destroy plan for a given configuration on an infrastructure component."
  task :"plan-destroy", [:config, :out] => :binary do |t, args|
    options = @options.merge({"name" => args[:config]})

    logger.info("Processing configuration for Terraform destroy plan...")

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

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

    runner.init(config: config)
    runner.plan(destroy: true, file: args[:out])
  end
end