YoCollabStackoverFlow
YoCollabStackoverFlow

Reputation: 77

How to import an existing Aurora MySQL cluster in a AWS CDK project/stack?

Is there a way to import an existing RDS aurora mysql cluster into a stack - that is NOT a serverless rds cluster?

I need to add some permissions and s3 bucket import property to an existing cluster.

Upvotes: 0

Views: 2473

Answers (1)

lynkfox
lynkfox

Reputation: 2400

CDK has nothing to do with serverless - it can set up (almost) any resource in AWS, serverless or not.

so while it depends on your language, you'd use something like: (python)

from aws_cdk import aws_rds as rds
 ....[in your stack init]
my_existing_rds = rds.DatabaseCluster.from_database_cluster_attributes(
    self, "ExistingRDS",
    cluster_identifier = "the cluster identifier"
)

as defined here: https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_rds/DatabaseCluster.html#aws_cdk.aws_rds.DatabaseCluster.from_database_cluster_attributes

Be aware. importing existing resources using the from* static methods of various resource constructs does not always give you access to updating all of their properties!!! For instance, importing a domain name with from_arn does NOT Give you the ability to get its host_zone! The import objects are useful, but ultimately not the preferred method of dealing with resources in CDK. (generally however, in response to your question, Role's are accessible)

Upvotes: 1

Related Questions