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
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!