Can't connect to database via RDS proxy

0

Hello,

I've created an Aurora Postgres database with a default proxy connected to it. But when I try to use it, it won't connect. I tried connecting with and without the signer. Here below is the code I used:

const signer = new Signer({
        /**
         * Required. The hostname of the database to connect to.
         */
        hostname: "PROXY-ENDPOINT",
        /**
         * Required. The port number the database is listening on.
         */
        port: 5432,
        /**
         * Required. The username to login as.
         */
        username: "DATABASE-USER",
        /**
         * Optional. The AWS credentials to sign requests with. Uses the default credential provider chain in not specified.
         */
        credentials: ****** (IAM admin credentials to test with)
        /**
         * Optional. The region the database is located in. Uses the region inferred from the runtime if omitted.
         */
        region: "eu-central-1",
    });
      
    const token = await signer.getAuthToken();

    console.log(token);

    const config = {
        client: "pg",
        connection: {
            timezone: "+00:00",
            host:  "PROXY-ENDPOINT",
            port: 5432,
            user: "DATABASE-USER",
            password: token,
            database: "DATABASE-NAME",
            ssl: "Amazon RDS"
        },
        pool: {
            min: 5, 
            max: 30,
            createTimeoutMillis: 30000,
            acquireTimeoutMillis: 30000,
            idleTimeoutMillis: 30000,
            reapIntervalMillis: 1000,
            createRetryIntervalMillis: 100
        },
    };

    const database = knex(config);

I use knex as database library and I used @aws-sdk/rds-signer to get the token. I've tested the code above locally and on a EC2 instance in the same VPC. Does somebody know what I did wrong?

Thanks for the help!

~Daan

已提問 1 年前檢視次數 824 次
1 個回答
0
已接受的答案

Hi, you may have an ip routing issue or a security group issue. That are the most 2 common root causes of such connectivity isse. I would suggest to telnet to your RDS proxy and see if you get the tcp session created.

If session is not created, it will confirm the routing or secgroup issue.

See https://netbeez.net/blog/telnet-to-test-connectivity-to-tcp/

profile pictureAWS
專家
已回答 1 年前
profile pictureAWS
專家
已審閱 1 年前
  • Thanks for your response. When I try to telnet to the proxy via my EC2 instance it keeps hanging on Trying 172.31.16.26... and after a while it tries a different internal ip address. But when I do the same thing with the direct connection endpoint it connects instantly. I've looked at the VPC ids and subnets, but they are all pointing to the same. Do you know what could be miss configured?

  • Check the security group on the proxy setup

  • Thanks it worked successfully!

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南