You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
makes it possible to bring an existing resource under CDK/CloudFormation's
466
+
management. See the [list of resources that can be imported here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html).
467
+
468
+
To import an existing resource to a CDK stack, follow the following steps:
469
+
470
+
1. Run a `cdk diff` to make sure there are no pending changes to the CDK stack you want to
471
+
import resources into. The only changes allowed in an "import" operation are
472
+
the addition of new resources which you want to import.
473
+
2. Add constructs for the resources you want to import to your Stack (for example,
474
+
for an S3 bucket, add something like `new s3.Bucket(this, 'ImportedS3Bucket', {});`).
475
+
**Do not add any other changes!** You must also make sure to exactly model the state
476
+
that the resource currently has. For the example of the Bucket, be sure to
477
+
include KMS keys, life cycle policies, and anything else that's relevant
478
+
about the bucket. If you do not, subsequent update operations may not do what
479
+
you expect.
480
+
3. Run the `cdk import` - if there are multiple stacks in the CDK app, pass a specific
481
+
stack name as an argument.
482
+
4. The CLI will prompt you to pass in the actual names of the resources you are
483
+
importing. After you supply it, the import starts.
484
+
5. When `cdk import` reports success, the resource is managed by CDK. Any subsequent
485
+
changes in the construct configuration will be reflected on the resource.
486
+
487
+
#### Limitations
488
+
489
+
This feature is currently in preview. Be aware of the following limitations:
490
+
491
+
- Importing resources in nested stacks is not possible.
492
+
- Uses the deploy role credentials (necessary to read the encrypted staging
493
+
bucket). Requires a new version (version 12) of the bootstrap stack, for the added
494
+
IAM permissions to the `deploy-role`.
495
+
- There is no check on whether the properties you specify are correct and complete
496
+
for the imported resource. Try starting a drift detection operation after importing.
497
+
- Resources that depend on other resources must all be imported together, or one-by-one
498
+
in the right order. The CLI will not help you import dependent resources in the right
499
+
order, the CloudFormation deployment will fail with unresolved references.
500
+
453
501
### `cdk destroy`
454
502
455
503
Deletes a stack from it's environment. This will cause the resources in the stack to be destroyed (unless they were
@@ -521,10 +569,10 @@ NOTICES
521
569
16603 Toggling off auto_delete_objects for Bucket empties the bucket
522
570
523
571
Overview: If a stack is deployed with an S3 bucket with
524
-
auto_delete_objects=True, and then re-deployed with
525
-
auto_delete_objects=False, all the objects in the bucket
572
+
auto_delete_objects=True, and then re-deployed with
573
+
auto_delete_objects=False, all the objects in the bucket
526
574
will be deleted.
527
-
575
+
528
576
Affected versions: <1.126.0.
529
577
530
578
More information at: https://github.com/aws/aws-cdk/issues/16603
@@ -533,12 +581,12 @@ NOTICES
533
581
17061 Error when building EKS cluster with monocdk import
534
582
535
583
Overview: When using monocdk/aws-eks to build a stack containing
536
-
an EKS cluster, error is thrown about missing
584
+
an EKS cluster, error is thrown about missing
537
585
lambda-layer-node-proxy-agent/layer/package.json.
538
-
586
+
539
587
Affected versions: >=1.126.0 <=1.130.0.
540
588
541
-
More information at: https://github.com/aws/aws-cdk/issues/17061
589
+
More information at: https://github.com/aws/aws-cdk/issues/17061
542
590
543
591
544
592
If you don’t want to see an notice anymore, use "cdk acknowledge ID". For example, "cdk acknowledge 16603".
@@ -580,7 +628,7 @@ $cdk acknowledge 16603
580
628
### `cdk notices`
581
629
582
630
List the notices that are relevant to the current CDK repository, regardless of context flags or notices that
583
-
have been acknowledged:
631
+
have been acknowledged:
584
632
585
633
```console
586
634
$ cdk notices
@@ -589,9 +637,9 @@ NOTICES
589
637
590
638
16603 Toggling off auto_delete_objects for Bucket empties the bucket
591
639
592
-
Overview: if a stack is deployed with an S3 bucket with
593
-
auto_delete_objects=True, and then re-deployed with
594
-
auto_delete_objects=False, all the objects in the bucket
640
+
Overview: if a stack is deployed with an S3 bucket with
641
+
auto_delete_objects=True, and then re-deployed with
642
+
auto_delete_objects=False, all the objects in the bucket
0 commit comments