Reputation: 215
I am creating an RDS cluster with an existing vpc. Following are the arguments given:
vpc: ec2.Vpc.fromLookup(this, "VPC", {vpcName: DEFAULT_VPC}),
engine: DatabaseClusterEngine.auroraPostgres({version: AuroraPostgresEngineVersion.VER_10_18}),
identifier: CLUSTER_IDENTIFIER,
dbSecretName: DATABASE_SECRET_NAME,
dbSecretUsername: DATABASE_SECRET_USERNAME,
databaseName: DATABASE_NAME,
enableDataApi: true,
removalPolicy: RemovalPolicy.RETAIN,
scaling: AURORA_SCALING_MAP.get(props.stage)!,
backupRetention: Duration.days(30)
But when deploying it is giving the error:
There are no 'Private' subnet groups in this VPC. Available types: Public
I verified that there are 3 subnets and all are public type. Can't rds cluster be created in public subnets? If so how can we specify that? How can private subnets be created from CDK if that is the path forward?
Upvotes: 1
Views: 814
Reputation: 636
A private zone is not a must in the case of RDS, and you can set the subnets to type explicitly in vpcSubnets.subnetType
parameter as follows:
declare const vpc: ec2.Vpc;
const cluster = new rds.DatabaseCluster(this, 'Database', {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
vpc,
},
});
Upvotes: 2