lib/terraspace/shell.rb
def mimic_terraform_input(stdin, stdout)
      shown = false
      patterns = [
        "Only 'yes' will be accepted", # prompt for apply. can happen on apply
        "\e[0m\e[1mvar.", # prompts for variable input. can happen on plan or apply. looking for bold marker also in case "var." shows up somewhere else
      ]
      while out = stdout.gets
        logger.info(out) unless shown && out.include?("Enter a value:")
        shown = false if out.include?("Enter a value:") # reset shown in case of multiple input prompts

        # Sometimes stdout doesnt flush and show "Enter a value: ", so mimic it
        if patterns.any? { |pattern| out.include?(pattern) }
          print "  Enter a value: ".bright
          shown = true
          stdin.write_nonblock($stdin.gets)
        end
      end
    end
# Terraform doesnt seem to stream the line that prompts with "Enter a value:" when using Open3.popen3
# Hack around it by mimicking the "Enter a value:" prompt
#
# Note: system does stream the prompt but using Open3.popen3 so we can capture output to save to logs.
Terraform doesnt seem to stream the line that prompts with "Enter a value:" when using Open3.popen3
Hack around it by mimicking the "Enter a value:" prompt

system does stream the prompt but using Open3.popen3 so we can capture output to save to logs.
Terraform doesnt seem to stream the line that prompts with " Enter a value : " when using Open3 . popen3 Hack around it by mimicking the " Enter a value : " prompt system does stream the prompt but using Open3 . popen3 so we can capture output to save to logs .
def mimic_terraform_input(stdin, stdout)
      shown = false
      patterns = [
        "Only 'yes' will be accepted", 
        "\e[0m\e[1mvar.", 
      ]
      while out = stdout.gets
        logger.info(out) unless shown && out.include?("Enter a value:")
        shown = false if out.include?("Enter a value:") 
        if patterns.any? { |pattern| out.include?(pattern) }
          print "  Enter a value: ".bright
          shown = true
          stdin.write_nonblock($stdin.gets)
        end
      end
    end
def mimic_terraform_input ( stdin , stdout ) shown = false patterns = [ "Only 'yes' will be accepted" , "\e[0m\e[1mvar." , ] while out = stdout . gets logger . info ( out ) unless shown && out . include? ( "Enter a value:" ) shown = false if out . include? ( "Enter a value:" ) if patterns . any? { | pattern | out . include? ( pattern ) } print "  Enter a value: " . bright shown = true stdin . write_nonblock ( $stdin . gets ) end end end
Terraform doesnt seem to stream the line that prompts with "Enter a value:" when using Open3.popen3
Hack around it by mimicking the "Enter a value:" prompt
Terraform doesnt seem to stream the line that prompts with " Enter a value : " when using Open3 . popen3 Hack around it by mimicking the " Enter a value : " prompt
# prompt for apply. can happen on apply # prompts for variable input. can happen on plan or apply. looking for bold marker also in case "var." shows up somewhere else # reset shown in case of multiple input prompts # Sometimes stdout doesnt flush and show "Enter a value: ", so mimic it
stdin
stdout