Describe the issue
The API documentation for aws_docdb.DatabaseCluster, for CDKv1 and CDKv2 shares the following sample code:
cluster = docdb.DatabaseCluster(self, "Database",
master_user=docdb.Login(
username="myuser", # NOTE: 'admin' is reserved by DocumentDB
exclude_characters=""@/:", # optional, defaults to the set ""@/" and is also used for eventually created rotations
secret_name="/myapp/mydocdb/masteruser"
),
instance_type=ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
vpc_subnets=ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PUBLIC
),
vpc=vpc
)
Deploying returns the following error, for both CDKv1 and v2:
Traceback (most recent call last):
File "................\lab\app.py", line 10, in <module>
LabStack(app, "LabStack",
File "................\python\current\lib\site-packages\jsii\_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "................\lab\lab\lab_stack.py", line 21, in __init__
instance_type=ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
File "................\python\current\lib\enum.py", line 437, in __getattr__
raise AttributeError(name) from None
AttributeError: R5
Subprocess exited with error 1
However, the following code works just fine:
db_class_type = ec2.InstanceClass.MEMORY5
db_class_size = ec2.InstanceSize.LARGE
vpc = ec2.Vpc(self, "VPC")
cluster = docdb.DatabaseCluster(self, "Database",
master_user=docdb.Login(
username="myuser"
),
instance_type=ec2.InstanceType.of(db_class_type, db_class_size),
vpc_subnets=ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PUBLIC
),
vpc=vpc
)
And synthesizes the following template:
"DatabaseInstance1844F58FD": {
"Type": "AWS::DocDB::DBInstance",
"Properties": {
"DBClusterIdentifier": {
"Ref": "DatabaseB269D8BB"
},
"DBInstanceClass": "db.r5.large"
},
One will notice the InstanceClass gets resolved to a R5 Large anyway. In accordance with the enum value.
While I am not quite sure why the R5 enum fails to work, despite it existing, the point is that to avoid such confusion for others, should we perhaps edit the documentation to reflect the MEMORY5 enum rather?
Links
https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_docdb/DatabaseCluster.html
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_docdb/DatabaseCluster.html
Describe the issue
The API documentation for aws_docdb.DatabaseCluster, for CDKv1 and CDKv2 shares the following sample code:
Deploying returns the following error, for both CDKv1 and v2:
However, the following code works just fine:
And synthesizes the following template:
One will notice the InstanceClass gets resolved to a R5 Large anyway. In accordance with the enum value.
While I am not quite sure why the R5 enum fails to work, despite it existing, the point is that to avoid such confusion for others, should we perhaps edit the documentation to reflect the MEMORY5 enum rather?
Links
https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_docdb/DatabaseCluster.html
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_docdb/DatabaseCluster.html