aws-rds: RDS Database Cluster support for GlobalDatabaseIdentifier
Describe the feature
Add GlobalClusterIdentifier parameter to rds DatabaseCluster construct, in order to be able to add database clusters to Global Aurora Databases, for example in different regions. The parameter is already supported through Cloudformation.
Use Case
I want to add a database cluster in a different region to my Aurora Global Database cluster using CDK. This should be possible through the GlobalClusterIdentifier parameter.
Proposed Solution
No response
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
CDK version used
2.40.0
Environment details (OS name and version, etc.)
OSX
This issue has been classified as p2. That means a workaround is available or it is deemed a nice-to-have feature. Given the amount of work there is to do and the relative priority of this issue, the CDK team is unlikely to address it. That does not mean the issue will never be fixed! If someone from the community submits a PR to fix this issue, and the PR is small and straightforward enough, and meets the quality bars to be reviewed and merged with little effort we will accept that PR. PRs that do not build or need complex or multiple rounds of reviews are unlikely to be merged and will be closed to keep our backlog manageable.
In the mean time, remember that you can always use the escape hatch (https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html) mechanism to have fine control over the CloudFormation output you want. We will keep the issue open for discoverability, to collect upvotes, and to facilitate discussion around this topic.
We use +1s on this issue to help prioritize our work, and are happy to re-evaluate the prioritization of this issue based on community feedback. You can reach out to the cdk.dev community on Slack (https://cdk.dev/) to solicit support for reprioritization.
For anyone who finds this in the future, this is how you can do what @corymhall describes above: https://gist.github.com/joshbalfour/385b0bbfa270e43078cda8468799b67a
@joshbalfour thanks for the link to your code. It'd be interesting to know how to do this is the context of pipelines (pipelines.CodePipeline). Here's the problem: in one pipeline stack a CfnGlobalCluster has been defined and deployed. In another pipeline stack (in another region) one would like to add a cluster as child to the already deployed CfnGlobalCluster except that in the cdk code the global cluster resource/reference/variable is not accessible so there is no way to reference it. Nor is there a way using Cfn constructs to import an existing resource (as far as I am aware).
Perhaps I can define the CfnGlobalCluster outside the context of the stack and pass it as a reference to the stack where I need it. I don't even think this is possible because I don't think Stack allows for custom properties. Even if this were possible this completely breaks the declarative philosophy of cdk and would require a step-wise implementation approach.
Honestly I think the only way around this is to have a cdk native construct which allows for importing of global cluster resources.
I guess one last implementation would be to spin up with all RDS resources completely outside of the pipeline Stack in each region, export the resource values, import the references in the pipeline stacks. I guess that would work albeit quite a hacky approach.
Hi @alpatekar
Thank you for raising this issue.
While this gets picked up, you can unblock yourself today without waiting for the L2 change — the L1 CfnDBCluster already supports this, so you can set it using the @aws-cdk/cfn-property-mixins CfnDBClusterPropsMixin:
import { aws_rds as rds } from '@aws-cdk/cfn-property-mixins';
databaseCluster.with(new rds.CfnDBClusterPropsMixin({
globalClusterIdentifier: 'my-global-cluster',
}));
This should unblock you immediately; let us know if this works for you.
Re: add DatabaseCluster to existing Aurora Global Database (#22212)
@alpatekar checked current aws-cdk-lib (2.267.0) — DatabaseClusterProps still has no way to join an existing Aurora Global Database.
The underlying L1 (CfnDBCluster.globalClusterIdentifier) is a genuine settable scalar, and you can set it with the shipped @aws-cdk/cfn-property-mixins package's CfnDBClusterPropsMixin. (Heads up on any comment claiming this is already solved elsewhere in the thread — I verified this independently against current source rather than taking that at face value.)
The fix
import * as cdk from 'aws-cdk-lib';
import * as rds from 'aws-cdk-lib/aws-rds';
import { aws_rds as rdsMixins } from '@aws-cdk/cfn-property-mixins';
const cluster = new rds.DatabaseCluster(this, 'Cluster', {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
writer: rds.ClusterInstance.provisioned('writer'),
vpc, // needs Private (with NAT) or Public subnets -- not Isolated
});
cluster.with(new rdsMixins.CfnDBClusterPropsMixin({
globalClusterIdentifier: 'my-existing-global-cluster',
}));
globalClusterIdentifier is a plain scalar, so the default combine() strategy is fine here — no rendering step needed.
Confirmed working
I verified this with a real synth: the resulting AWS::RDS::DBCluster correctly picks up GlobalClusterIdentifier. Note for the repro: DatabaseCluster needs a VPC with Private (NAT-backed) or Public subnets — Isolated subnets or natGateways: 0 will fail placement.
This response was posted by an AI agent operating on behalf of @mrgrain.