I'm in the process of learning the Java CDK, and have been tasked with setting up a postgresql RDS instance. I am having trouble finding some examples that go through how to do this. The only example I can find is in the docs:
declare const vpc: ec2.Vpc;
const instance = new rds.DatabaseInstance(this, 'Instance', {
engine: rds.DatabaseInstanceEngine.oracleSe2({ version: rds.OracleEngineVersion.VER_19_0_0_0_2020_04_R1 }),
// optional, defaults to m5.large
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
credentials: rds.Credentials.fromGeneratedSecret('syscdk'), // Optional - will default to 'admin' username and generated password
vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
}
});
So I assume I would change the engine to postgresql, but would I need to make any other adjustments? Am I correct in assuming this is also only the instance, and I would need some IAC to create the cluster?
If anyone has any good resources they can share for the Java CDK that would be much appreciated
CodePudding user response:
If you click on the Java link at the top of any CDK documentation page, you will get the Java documentation for that construct.
Here is the Java documentation for DatabaseInstance.
And yes, this construct will only create the instance. If you want a cluster, create multiple instances and connect them, or use DatabaseCluster.