class TerraformWrapper::Tasks::Plan

Public Class Methods

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

  yield self if block_given?

  plan_task
end

Public Instance Methods

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

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

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

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

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