class Ruby::Terraform::Commands::ApplyCommand
Attributes
auto_approve[RW]
dir[RW]
state[RW]
vars[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/ruby/terraform/commands/apply_command.rb, line 12 def initialize(opts = {}) @dir = opts[:dir] @state = opts[:state] @vars = opts[:vars] @auto_approve = if opts[:auto_approve].nil? true else opts[:auto_approve] end end
Public Instance Methods
command()
click to toggle source
# File lib/ruby/terraform/commands/apply_command.rb, line 23 def command cmd = %W[#{tf_binary} apply] cmd += ['-state', state] if state cmd += ['-auto-approve'] if auto_approve if vars vars.each do |key, value| var_value = value.is_a?(String) ? value : JSON.generate(value) cmd += ['-var', "#{key}=#{var_value}"] end end cmd += [dir] if dir cmd end