in src/proxysql.ts [118:158]
constructor(scope: Construct, id: string, props: DBProps ) {
super(scope, id);
// Aurora
const dbcluster = new rds.DatabaseCluster(this, 'Database', {
engine: props.engine ?? rds.DatabaseClusterEngine.AURORA,
// masterUser: {
// username: props.masterUsername ?? DB_MASTER_USERNAME ?? 'admin',
// },
instanceProps: {
instanceType: props.instanceType ?? new ec2.InstanceType('t3.small'),
vpc: props.vpc,
},
parameterGroup: new rds.ParameterGroup(this, 'PG', {
engine: props.engine ?? rds.DatabaseClusterEngine.AURORA,
// engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL
// engine: (props.engine === rds.DatabaseClusterEngine.AURORA_POSTGRESQL) ? 'aurora-postgresql11' : 'default.aurora5.6',
// family: (props.engine === rds.DatabaseClusterEngine.AURORA_POSTGRESQL) ? 'aurora-postgresql11' : 'default.aurora5.6',
}),
removalPolicy: RemovalPolicy.DESTROY,
});
// allow internally from the same security group
dbcluster.connections.allowInternally(ec2.Port.tcp(AURORA_LISTENER_PORT));
// allow from the whole vpc cidr
dbcluster.connections.allowFrom(ec2.Peer.ipv4(props.vpc.vpcCidrBlock), ec2.Port.tcp(AURORA_LISTENER_PORT) );
this.dbcluster = dbcluster;
this.vpc = props.vpc;
this.clusterEndpointHostname = dbcluster.clusterEndpoint.hostname;
this.clusterReadEndpointHostname = dbcluster.clusterReadEndpoint.hostname;
this.clusterIdentifier = dbcluster.clusterIdentifier;
printOutput(this, 'clusterEndpointHostname', this.clusterEndpointHostname );
printOutput(this, 'clusterReadEndpointHostname', this.clusterReadEndpointHostname);
printOutput(this, 'clusterIdentifier', this.clusterIdentifier);
if (dbcluster.secret) {
printOutput(this, 'DBSecretArn', dbcluster.secret.secretArn);
}
}