class TerraformWrapper::Tasks::Apply

Public Class Methods

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

  yield self if block_given?

  apply_task
end

Public Instance Methods

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

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

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

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

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