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 年前825 查看次数
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!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则