-
Notifications
You must be signed in to change notification settings - Fork 82
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
Support resource import #52
Comments
This looks like a duplicate of this issue |
I am confused about the Importing Existing External Resources from the developer docs. It looks likes it is a different thing than this, right? |
This would be of great help, especially when getting to grips with the CDK and learning about AWS services. For example I've set up some proof-of-concept stuff to show my team, but now want to manage it via a CDK template. I'm probably going to have to destroy and recreate, but if i was able to run the cdk with an |
Pulumi is more clear about it: they talk about A clear distinction between |
@marcindulak has a very good point; the documentation describes a clear path to referencing external resources, which is definitely a useful feature, but the use case of being able to adopt them isn't. In the short term it would be good to clarify those terms in the documentation and indicate that adoption is not presently supported. For my part, at least, I can't use CDK in my personal work until it does support that, since everything I'm doing in hobby terms both a) stores state and b) was initially created using Terraform :) |
If you want to import existing resource into a new stack, I've had some success running |
I wrote in my duplicate issue that I'd like AWS CDK to work as transparently as possible. For instance, if I delete a stack with named & retained resources, and then create the stack again, AWS CDK could automatically detect and import those retained resources back into the new stack, perhaps with a simple confirmation prompt. This happens to me personally usually with retained S3 buckets and DynamoDB tables. This transparent orphan-adoption would make it simple to recreate stacks and also to split larger stacks that have hit the 200 resource limit. Sometimes you also want to move resources around just to refactor your architecture. At present stacks are pretty rigid if you have data in your buckets or tables, which discourages refactoring. |
@kennu woah, that functionality would be absolutely transformative in how teams work with CDK! |
Is there any plan to provide support for the requirement @kennu as requested for ? |
The use case that brought me to this issue is DynamoDB recoveries. If I build a CDK application with DynamoDB in it, then have to restore the database, I can import the restored database by reference (CDK "import") or create a new DynamoDB table and migrate the data. In CloudFormation "import" I can bring in the restored table and still manage its structure. |
anyone tried to import kinesis Delivery stream to Cloudformation using CDK ? |
For example: const firehose = kinesisfirehose.CfnDeliveryStream.fromArn(myImportedFirehoseArn);
const eventRule = new eventBus.Rule(this, `salesforce-eventbus-eventlake-rule-${this.id}`, {
enabled: true,
description: `Send all events to event lake for ${this.id}.`,
ruleName: `salesforce-eventbus-eventlake-rule-${this.id}`,
eventBus: bus,
targets: [
new eventsTarget.KinesisFirehoseStream(firehose)
],
eventPattern: {
source: [ { prefix: "" } ] as any[] // send all events to event lake
}
}); |
+1 This would helpful functionality when you restore an RDS DB Cluster and would like to adopt/import that new cluster into an existing stack. Something I’m working through now. |
+1 Same here, for S3 Bucket or any DB it will be amazing to have choice between create or import a resource if it exist. |
This feature would be very useful. My use case is migrating resources created by Terraform to be managed by CDK. |
Yes this feature is really missing in CDK. For example... if you have a SNS -> SQS -> Lambda . And your CDK manages the SQS and the lambda and for whatever reason you need to delete the cloudformation you surely would like the SQS to be there (in order not to miss any event). Then when recreating the cloudformation it should automatically import the SQS again. |
How can we make sure this feature gets the right attention? |
An initial version of `cdk import`, bringing existing resources under the management of CloudFormation. To use: - Make sure your diff is clean (you've recently deployed) - Add constructs for the resource(s) you want to import. **Make sure the CDK code configures them exactly as they are configured in reality**. - You can provide resource names here but it's probably better if you don't. - Run `cdk import` - Provide the actual resource names for each resource (if necessary). - An importing changeset will execute and the resources are imported. This is an implementation of aws/aws-cdk-rfcs#52
Worth noting that as of |
An initial version of `cdk import`, bringing existing resources under the management of CloudFormation. To use: - Make sure your diff is clean (you've recently deployed) - Add constructs for the resource(s) you want to import. **Make sure the CDK code configures them exactly as they are configured in reality**. - You can provide resource names here but it's probably better if you don't. - Run `cdk import` - Provide the actual resource names for each resource (if necessary). - An importing changeset will execute and the resources are imported. This is an implementation of aws/aws-cdk-rfcs#52
When this is released will something like this work? var existingBucket = Bucket.FromBucketName(this, "mybucketid", "mybucket");
if (existingBucket is null)
{
new Bucket(
this,
"mybucketid",
new BucketProps
{
BucketName = "mybucket",
RemovalPolicy = RemovalPolicy.RETAIN,
}
);
} The docs says to run |
I don't see how anyone can live without this feature. As we know, things in SaaS go wrong, and they need to be fixed as fast as possible. It makes for a very brittle stack if we can't easily create/update resources from the AWS console (e.g. restore an rds instance from a snapshot). CDK wants nothing to do with those if you don't modify your code. Furthermore, even if you modify the code to import them, they are not managed properly and are just unmanaged references. |
Feature has been implemented for a while now. Sorry for the poor bookkeeping. Closing |
@rix0rrr is there plans to bring the feature out of preview? As far as I'm aware, it's still only GitHub documented and has noted limitations. |
@rix0rrr Could you provide some more details? It would be appreciated if you could link to the implementation, user guide, something before closing out the issue so the people subscribed to this issue could learn more. Thanks! |
I can see it's implemented and merged to master aws/aws-cdk#17666 |
Description
CloudFormation released resource import
How should we support it in the CDK?
See #84 for a related feature/discussion.
Progress
The text was updated successfully, but these errors were encountered: