Issue
I am trying to deploy a DocumentDB instance using AWS CDK docdb
package (Java) and I keep getting this error:
Invalid DB Instance class: db.d2.large (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterValue; Request
ID: 41494b4b-d14f-46ff-b077-9ee73aad515f; Proxy: null)
I know that, for example, an r5.large
would work, but I cannot find a way to map from the InstanceType
enum values (STANDARDx
, STORAGE2
, etc.) to the actual AWS Instance type; it does not appear to be documented anywhere, and the example (in TypeScript) use happily something like instanceType: 'r5.large'
and move on.
This is my code, for completeness:
DatabaseCluster dbCluster = DatabaseCluster.Builder.create(scope, "ApiDocDb")
.dbClusterName(dataProps.getTableName())
.masterUser(Login.builder()
.username(masterUsername)
.password(SecretValue.plainText(masterPwd))
.build())
.instanceType(InstanceType.of(InstanceClass.STORAGE2, InstanceSize.LARGE))
.vpc(Vpc.Builder.create(scope, "DocDB-VPC")
.cidr("10.2.0.0/16")
.build())
.vpcSubnets(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build())
.build();
Solution
By trial and error (largely) I finally arrived at this:
.instanceType(InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE))
which seems to work.
Some help from this page - cross-correlating with the fact that, in the console, if one tries to add an instance, only r5
are allowed in the drop-down.
I just wish AWS had documented that enum a bit better.
Answered By - Marco Massenzio