title: connecting to amazon rds with psycopg2 via lambda
body: <p>my code on aws lambda:</p>
  
  <pre><code>import sys, boto3, logging, rds_config, psycopg2
  
  rds_host = "hostname"
  name = rds_config.db_username
  password = rds_config.db_password
  db_name = rds_config.db_name
  
  s3 = boto3.resource('s3')
  rds_client = boto3.client('rds',aws_access_key_id=Access_Key,aws_secret_access_key=Secret_Access_Key)
  instances = rds_client.describe_db_instances()
  print (instances)
  
  try:
      conn = psycopg2.connect(host=rds_host,
                          database=db_name,
                          user=name,
                          password=password)
      cur = conn.cursor()
  
  except:
      logger.error("ERROR: Unexpected error: Could not connect to Postgresql instance.")
      sys.exit()
  </code></pre>
  
  <p>I believe I have with boto3.client connected to RDS Instance because the info of instance is outputed to screen.</p>
  
  <p>But with psycopg2 that will not do.<br>
  And instead of logger.error I got the time out error message:</p>
  
  <pre><code>Task timed out after 60.06 seconds
  </code></pre>
  
  <p>in addition:
  I can connect to RDS either with my local psql console or with python script from my local server. Only if I test the script with aws-lambda online, it doesn´t work</p>
  
  <p>Any help Regarding this?
  Thank you!</p>