Import RDS Instance from Account B to Account using cdk import

0

I have an RDS Instance in Account B and I want to import an RDS instance to a Stack I have created in Account A , I followed this Article guide https://aws.amazon.com/blogs/devops/how-to-import-existing-resources-into-aws-cdk-stacks/ using cdk import and as i understood , I just put in my CDK code something like

new s3.Bucket(this, 'ImportedS3Bucket', {})

but in my case i want to import an RDS instance , but whenever I add the following block of code

`new rds.DatabaseInstance(this, 'ImportedRDS', {

})`

It need me to pass further properties unlike using former Block of code using S3

My questions :

1- Does every resource I want to import differs in the properties that i need to pass ? like for S3 bucket I needn't to pass any property unlike the RDS import in the second block of code ?

2- Is it valid to import an RDS instance from another account i.e. Account B to a stack which is in Account A ? if is it valid , is it the best approach ? also, do I get billed twice ? one for the RDS which is in Account B and one for the Imported one into Account A.

2 Answers
1

As mentioned here: https://github.com/aws/aws-cdk/blob/v1-main/packages/aws-cdk/README.md#cdk-import

You must also make sure to exactly model the state that the resource currently has. For the example of the Bucket, be sure to include KMS keys, life cycle policies, and anything else that's relevant about the bucket. If you do not, subsequent update operations may not do what you expect

So in your case, as the s3 construct may default to certain properties if not specified, the same may apply for rds.

I would suggest you to be explicit and define properties based on the construct: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseInstance.html to avoid any surprise

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • thanks so much , what about the billing part ? i.e. Is it valid to import an RDS instance from another account i.e. Account B to a stack which is in Account A ? if is it valid , is it the best approach ? also, do I get billed twice ? one for the RDS which is in Account B and one for the Imported one into Account A.

  • Is it valid to import an RDS instance from another account (Account B) to a stack in Account A?

    Yes, it is valid to import an RDS instance from one AWS account to another using cross-account IAM roles.


    Is it the best approach?

    Using cross-account services can be a viable approach, but whether it is the best option depends on your specific use case, as well as considerations related to security, management, and compliance.


    Do I get billed twice, one for the RDS in Account B and one for the imported one into Account A?

    No, you will not be billed twice. The billing will continue to be based on the account where the RDS instance is physically located (Account B). (Note: you are accessing the existing instance in Account B from Account A. In this scenario, you will not be billed twice)

0

Thanks so much. Appreciate it.

Mahmoud
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions