I have tried configuring the RDS cluster using cluster.connections.allowDefaultPortFromAnyIpv4();
but still I am not able to connect to my postgres instance, it keeps timing out.
I've been trying to figure this out from 2 days but still no luck, not sure what to do
Here is the full code for CDK config.
import { CdkWorkshopStack } from "../stacks/cdk-workshop-stack";
import * as rds from "@aws-cdk/aws-rds";
import * as ec2 from "@aws-cdk/aws-ec2";
import { ServerlessCluster } from "@aws-cdk/aws-rds";
import { Duration } from "@aws-cdk/core";
export const createDbInstance = (
scope: CdkWorkshopStack
): { cluster: ServerlessCluster; dbName: string } => {
// Create the VPC needed for the Aurora Serverless DB cluster
const vpc = new ec2.Vpc(scope, "AuroraVPC");
const dbName = "yt_backup";
// Create the Serverless Aurora DB cluster; set the engine to Postgres
const cluster = new rds.ServerlessCluster(scope, "yt_backup_cluster", {
engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
parameterGroup: rds.ParameterGroup.fromParameterGroupName(
scope,
"ParameterGroup",
"default.aurora-postgresql10"
),
defaultDatabaseName: dbName,
//@ts-ignore
vpc: vpc,
//@ts-ignore
scaling: { autoPause: Duration.minutes(10) }, // Optional. If not set, then instance will pause after 5 minutes
});
cluster.connections.allowDefaultPortFromAnyIpv4();
return { cluster, dbName };
};