title: Connect to AWS RDS PostgreSQL with AWS Lambda and Golang
body: <p>I am trying to connect to a AWS RDS PosgreSQL database from a lambda in Go.</p>
  
  <p>The <code>authToken</code> seems good in the logs.</p>
  
  <pre><code>creds := credentials.NewEnvCredentials()
  authToken, err := rdsutils.BuildAuthToken("something.eu-west-3.rds.amazonaws.com", "eu-west-3", "Username", creds)
  
  if err != nil {
      fmt.Println("Cannot create db auth token")
      return response.Status(500), err
  }
  
  // Create the DNS string for the DB connection
  // // user:password@protocol(endpoint:port)/dbname?&lt;params&gt;
  dnsStr := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=verify-full",
      "Username", authToken, "something.eu-west-3.rds.amazonaws.com", "table_name",
  )
  db, err := sql.Open("postgres", dnsStr)
  
  if err != nil {
      fmt.Println("Cannot open db")
      return response.Status(500), err
  }
  
  err = db.Ping()
  
  if err != nil {
      fmt.Println("Cannot ping db")
      return response.Status(500), err
  }
  
  fmt.Println("Connection established")
  </code></pre>
  
  <p>I have an error on the <code>db.Ping()</code>, and in the logs I got</p>
  
  <pre><code>Cannot ping db
  dial tcp: address tcp/something.eu-west-3.rds.amazonaws.com: unknown port: OpError
  null
  </code></pre>
  
  <p>I use the <code>pq</code> library, imported as <code>_ "github.com/lib/pq"
  </code></p>
  
  <p>I have tried adding the default port <code>5432</code> in the url after the host, but with no results.</p>
  
  <p>I'm sure I'm missing a stupid key point, plz halp</p>