docs: def create_ssh_command(session, instance_id, instance_name, username, key_file, port, ssh_options,
                         use_private_ip, gateway_instance_id, gateway_username):
      """Create SSH Login command string"""
      ec2 = session.resource('ec2')
      if instance_id is not None:
          try:
              instance = ec2.Instance(instance_id)
              hostname = _get_instance_ip_address(instance, use_private_ip)
          except botocore.exceptions.ClientError as e:
              click.echo("Invalid instance ID {0} ({1})".format(instance_id, e), err=True)
              sys.exit(2)
      elif instance_name is not None:
          try:
              conditions = [
                  {'Name': 'tag:Name', 'Values': [instance_name]},
                  {'Name': 'instance-state-name', 'Values': ['running']},
              ]
              instances = ec2.instances.filter(Filters=conditions)
              target_instances = []
              for idx, i in enumerate(instances):
                  target_instances.append(i)
              if len(target_instances) == 1:
                  instance = target_instances[0]
                  hostname = _get_instance_ip_address(instance, use_private_ip)
              else:
                  for idx, i in enumerate(instances):
                      tag_name = get_tag_value(i.tags, 'Name')
                      click.echo('[{0}]: {1}\t{2}\t{3}\t{4}\t{5}'.format(
                          idx, i.id, i.public_ip_address, i.state['Name'], tag_name, i.key_name))
                  selected_idx = click.prompt("Please enter a valid number", type=int, default=0)
                  if len(target_instances) - 1 < selected_idx or selected_idx < 0:
                      click.echo("selected number [{0}] is invalid".format(selected_idx), err=True)
                      sys.exit(2)
                  click.echo("{0} is selected.".format(selected_idx))
                  instance = target_instances[selected_idx]
                  hostname = _get_instance_ip_address(instance, use_private_ip)
          except botocore.exceptions.ClientError as e:
              click.echo("Invalid instance ID {0} ({1})".format(instance_id, e), err=True)
              sys.exit(2)
      # TODO: need to refactor and make it testable
      if key_file is None:
          key_file_option = ''
      else:
          key_file_option = ' -i {0}'.format(key_file)
  
      gateway_username_option = build_option_username(gateway_username)
      username_option = build_option_username(username)
  
      if ssh_options is None:
          ssh_options = ''
      else:
          ssh_options = ' {0}'.format(ssh_options)
      if gateway_instance_id is not None:
          gateway_instance = ec2.Instance(gateway_instance_id)
          gateway_public_ip = gateway_instance.public_ip_address
          hostname = instance.private_ip_address
          cmd = 'ssh -tt{0} {1}{2} -p {3}{4} ssh{5} {6}'.format(
              gateway_username_option, gateway_public_ip, key_file_option,
              port, ssh_options, username_option, hostname)
      else:
          cmd = 'ssh{0} {1}{2} -p {3}{4}'.format(username_option, hostname, key_file_option, port, ssh_options)
      return cmd