module Ruby module Terraform module Commands class PlanCommand include ExecutionSupport attr_accessor :dir attr_accessor :state attr_accessor :vars def initialize(opts = {}) @dir = opts[:dir] @state = opts[:state] @vars = opts[:vars] end def command cmd = %W[#{tf_binary} plan] cmd += ['-state', state] if state 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 end end end end