def wait_for(opts = {})
      aws_object = opts[:aws_object]
      query_method = opts[:query_method]
      expected_responses = [opts[:expected_responses]].flatten
      acceptable_errors = [opts[:acceptable_errors] || []].flatten
      tries = opts[:tries] || 60
      sleep = opts[:sleep] || 5

      Retryable.retryable(tries: tries, sleep: sleep) do |retries, exception|
        action_handler.report_progress "waited #{retries * sleep}/#{tries * sleep}s for <#{aws_object.class}:#{aws_object.id}>##{query_method} state to change to #{expected_responses.inspect}..."
        Chef::Log.debug("Current exception in wait_for is #{exception.inspect}") if exception
        begin
          yield(aws_object) if block_given?
          if aws_object.class.to_s.eql?("Aws::EC2::Vpc")
            vpc = new_resource.driver.ec2.describe_vpcs(vpc_ids: [aws_object.vpc_id]).vpcs
            current_response = "[:#{vpc[0].state}]"
          elsif aws_object.class.to_s.eql?("Aws::EC2::NetworkInterface")
            result = new_resource.driver.ec2_resource.network_interface(aws_object.id)
            current_response = "[:#{result.status}]"
            current_response = "[:in_use]" if current_response.eql?("[:in-use]")
          elsif aws_object.class.to_s.eql?("Aws::EC2::NatGateway")
            current_response = "[:#{aws_object.state}]"
          end
          Chef::Log.debug("Current response in wait_for from [#{query_method}] is #{current_response}")
          unless expected_responses.to_s.include?(current_response)
            raise StatusTimeoutError.new(aws_object, current_response, expected_responses)
          end
        rescue *acceptable_errors
        end
      end
    end
def wait_for(opts = {})
      aws_object = opts[:aws_object]
      query_method = opts[:query_method]
      expected_responses = [opts[:expected_responses]].flatten
      acceptable_errors = [opts[:acceptable_errors] || []].flatten
      tries = opts[:tries] || 60
      sleep = opts[:sleep] || 5

      Retryable.retryable(tries: tries, sleep: sleep) do |retries, exception|
        action_handler.report_progress "waited #{retries * sleep}/#{tries * sleep}s for <#{aws_object.class}:#{aws_object.id}>##{query_method} state to change to #{expected_responses.inspect}..."
        Chef::Log.debug("Current exception in wait_for is #{exception.inspect}") if exception
        begin
          yield(aws_object) if block_given?
          if aws_object.class.to_s.eql?("Aws::EC2::Vpc")
            vpc = new_resource.driver.ec2.describe_vpcs(vpc_ids: [aws_object.vpc_id]).vpcs
            current_response = "[:#{vpc[0].state}]"
          elsif aws_object.class.to_s.eql?("Aws::EC2::NetworkInterface")
            result = new_resource.driver.ec2_resource.network_interface(aws_object.id)
            current_response = "[:#{result.status}]"
            current_response = "[:in_use]" if current_response.eql?("[:in-use]")
          elsif aws_object.class.to_s.eql?("Aws::EC2::NatGateway")
            current_response = "[:#{aws_object.state}]"
          end
          Chef::Log.debug("Current response in wait_for from [#{query_method}] is #{current_response}")
          unless expected_responses.to_s.include?(current_response)
            raise StatusTimeoutError.new(aws_object, current_response, expected_responses)
          end
        rescue *acceptable_errors
        end
      end
    end
Wait until aws_object obtains one of expected_responses

 @param aws_object Aws SDK Object to check state on
 @param query_method Method to call on aws_object to get current state
 @param expected_responses [Symbol,Array<Symbol>] Final state(s) to look for
 @param acceptable_errors [Exception,Array<Exception>] Acceptable errors that are caught and squelched
 @param tries [Integer] Number of times to check state, defaults to 60
 @param sleep [Integer] Time to wait between checking states, defaults to 5