Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDS - Import existing DatabaseInstance from ARN #7295

Closed
Dzhuneyt opened this issue Apr 10, 2020 · 10 comments
Closed

RDS - Import existing DatabaseInstance from ARN #7295

Dzhuneyt opened this issue Apr 10, 2020 · 10 comments
Assignees
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closing-soon This issue will automatically close in 4 days unless further comments are made. feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@Dzhuneyt
Copy link
Contributor

Currently the AWS CDK only allows creating a DB instance. It would be great to be able to import and reuse existing RDS instances.

Use Case

Creating a CI pipeline that automatically provisions QA "sandboxes" of the app, that are all connected and reuse the same DB instance.

Because of this use case.

Proposed Solution

DatabaseInstance.fromArn();


This is a 🚀 Feature Request

@Dzhuneyt Dzhuneyt added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 10, 2020
@jogold
Copy link
Contributor

jogold commented Apr 10, 2020

You should be able to use fromDatabaseInstanceAttributes for this:

public static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance {

@SomayaB SomayaB added the @aws-cdk/aws-rds Related to Amazon Relational Database label Apr 11, 2020
@nija-at
Copy link
Contributor

nija-at commented Apr 22, 2020

Hi @Dzhuneyt -

Let us know if the API that @jogold has referred to above does not satisfy your use case.

Marking this issue as closing soon.

@nija-at nija-at added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Apr 22, 2020
@mariusingjer
Copy link

It would be great with an example of how this is supposed to work. The suggestion from the author is to import based on arn, the method referred to is requiring instance identifier, port, security group ++. Whats the suggested solution here? To export everything required by the fromInstanceAttributes?

@romor
Copy link

romor commented Dec 27, 2020

It would be great with an example of how this is supposed to work.

Not sure whether this is correct, but I would try it like this:

const db = rds.DatabaseInstance.fromDatabaseInstanceAttributes(this, "myDb", {
      instanceIdentifier: "db-name",
      instanceEndpointAddress: "db-arn",
      port: 5432,
      securityGroups: [],
});

@zilahir
Copy link

zilahir commented Aug 19, 2023

@romor not really :) the question was whether it's possible to get an RDS instance by it's arn. The example you provided, even you are not doing that, the instanceEndpointAddress is not takes an arn, it takes an url. So this is still a desired feature request.

@rverton
Copy link

rverton commented Jan 22, 2024

Also looking for a solution to this, as @zilahir already mentioned, fromDatabaseInstanceAttributes solves a different purpose in my understanding, because you need to pass all attributes manually. @nija-at can you reopen this?

@gshpychka
Copy link
Contributor

The L2 construct needs more information than the ARN to function, so you cannot only reference it by ARN.

To be clear - this function does not do a lookup or any API call, it is just a read-only reference to some resources, so you need to provide all the information it needs to it.

@JoshMcCullough
Copy link

JoshMcCullough commented Oct 9, 2024

I think what we're looking for here is "simply" a way to not have to provide all of these seemingly extraneous details (instanceEndpointAddress, port, securityGroups). I'm sure it's more complicated than I/we realize, but the ask is for a lookup function where we can pass the instanceIdentifier (and nothing else ... maybe region).

@gshpychka
Copy link
Contributor

I think what we're looking for here is "simply" a way to not have to provide all of these seemingly extraneous details (instanceEndpointAddress, port, securityGroups).

Since this is not a lookup (as mentioned above, it does not perform any API calls), it needs all information required by the methods/props that IDatabaseInstance provides.

What you're asking for is a "lookup", which is reasonable, but doesn't exist at all for RDS yet - I would open a new feature request for a lookup function for RDS instances.

@JoshMcCullough
Copy link

Yes, asking for a lookup -- exactly.

Submitted a new feature request, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closing-soon This issue will automatically close in 4 days unless further comments are made. feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

10 participants