title: AWS UNLOAD invalid credentials clause
body: <p>I'm trying to unload data from AWS Redshift to an s3 bucket. The Redshift cluster is additionally password protected. I set up the aws cli to use an appropriate key pair and tested with success. I am able to access the Redshift cluster with DataGrip with my credentials, but now when I try to unload using following script in python3</p>
  
  <pre><code>import json
  import os
  import psycopg2
  
  
  def run(config_json, sql_query):
  
      conn = psycopg2.connect(**config_json['db'])
      cursor = conn.cursor()
  
      query = """
          UNLOAD ($${}$$)
          to \'{}\'
          parallel off
          delimiter ','
          allowoverwrite;
          """.format(sql_query, config_json['s3bucket_path_to_file'])
      print("The following UNLOAD query is being run: \n" + query)
      cursor.execute(query)
      print('Completed write to {}'.format(config_json['s3bucket_path_to_file']))
  
  
  if __name__ == '__main__':
      config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.json')
      with open(config_path, 'r') as f:
          config = json.loads(f.read())
  
      query_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'query.sql')
      with open(query_path, 'r') as f:
          query_sql = f.read()
  
      run(config, query_sql)
  </code></pre>
  
  <p>I get following error </p>
  
  <pre><code>psycopg2.InternalError: invalid CREDENTIALS clause
  DETAIL:  
    -----------------------------------------------
    error:  invalid CREDENTIALS clause
    code:      8001
    context:   
    query:     2820791
    location:  aws_credentials_parser.cpp:62
    process:   padbmaster [pid=25330]
    -----------------------------------------------
  </code></pre>
  
  <p>the <code>config.json</code> file has the following format:</p>
  
  <pre><code>{
    "db": {
      "dbname": "dbname",
      "user": "user1",
      "host": "someip",
      "password": "very secret psw",
      "port": "1111"
    },
    "s3bucket_path_to_file": "s3://bucket-name/path/to/file.csv"
  }
  </code></pre>