Class: RakeTerraform::ApplyTask::Task

Inherits:
BaseTask
  • Object
show all
Includes:
TerraformCmd
Defined in:
lib/rake-terraform/apply_task/task.rb

Overview

Custom rake task to run ‘terraform apply`

Instance Method Summary collapse

Methods included from TerraformCmd

#tf_apply, #tf_get, #tf_init, #tf_plan, #tf_show

Methods inherited from BaseTask

#terraform_installed?, #validate_terraform_installed

Constructor Details

#initialize(opts) ⇒ Task

Returns a new instance of Task.



11
12
13
# File 'lib/rake-terraform/apply_task/task.rb', line 11

def initialize(opts)
  @opts = opts
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rake-terraform/apply_task/task.rb', line 15

def execute
  plan = @opts.get(:plan)
  pre_execute_checks(plan)
  Dir.chdir(@opts.get(:execution_path)) do
    if @opts[:unique_state]
      tf_apply(plan, @opts[:state_file])
    else
      tf_apply(plan)
    end
  end
end