module RakeTerraform::TerraformCmd

RakeTerraform::TerraformCmd

Helper module for running wrapping terraform calls

TODO: refactor public methods to take splat arguments and write private

command builder methods

Public Instance Methods

tf_apply(plan_file, state_file = nil) click to toggle source

perform a 'terraform apply'

# File lib/rake-terraform/terraformcmd.rb, line 45
def tf_apply(plan_file, state_file = nil)
  cmd = 'terraform apply'
  state_file && cmd << " -state #{state_file}"
  cmd << " #{plan_file}"
  system(cmd)
end
tf_get(update = false) click to toggle source

perform a 'terraform get'

# File lib/rake-terraform/terraformcmd.rb, line 11
def tf_get(update = false)
  cmd = 'terraform get'
  update && cmd << ' -update'
  system(cmd)
end
tf_init() click to toggle source

perform a 'terraform init'

# File lib/rake-terraform/terraformcmd.rb, line 19
def tf_init
  cmd = 'terraform init'
  system(cmd)
end
tf_plan(output_file = nil, state_file = nil, module_depth = 2) click to toggle source

perform a 'terraform plan'

# File lib/rake-terraform/terraformcmd.rb, line 26
def tf_plan(output_file = nil, state_file = nil, module_depth = 2)
  cmd = 'terraform plan'
  cmd << " -module-depth #{module_depth}"
  state_file && cmd << " -state #{state_file}"
  output_file && cmd << " -out #{output_file}"
  system(cmd)
end
tf_show(plan_file, module_depth = 2) click to toggle source

perform a 'terraform show'

# File lib/rake-terraform/terraformcmd.rb, line 36
def tf_show(plan_file, module_depth = 2)
  cmd = 'terraform show'
  cmd << " -module-depth #{module_depth}"
  cmd << " #{plan_file}"
  system(cmd)
end