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

feat(cli): support CloudFormation simplified resource import #29087

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0f8965f
feat(cli): support ImportExstingResources
tmokmss Nov 19, 2023
e42494e
update aws-sdk, but I'm not sure if it's allowed
tmokmss Nov 19, 2023
ca9cd25
Update cli.integtest.ts
tmokmss Nov 19, 2023
e803106
fix integ
tmokmss Nov 20, 2023
a2fa8b4
also update aws-sdk
tmokmss Nov 20, 2023
d66b937
Update deployments.ts
tmokmss Nov 20, 2023
7e04e54
possible refactor to remove dead code
tmokmss Nov 20, 2023
30c1e50
revert refactor; might do this in another PR
tmokmss Nov 20, 2023
86f6ebc
Merge branch 'main' into allow_import_resources
tmokmss Nov 20, 2023
9229d92
Merge branch 'main' into allow_import_resources
tmokmss Dec 7, 2023
3a2a739
Update yarn.lock
tmokmss Dec 7, 2023
2a6aae5
Update README.md
tmokmss Dec 13, 2023
07fa306
Update cli.integtest.ts
tmokmss Dec 13, 2023
526daed
Update README.md
tmokmss Dec 13, 2023
d5f41e6
Update deploy-stack.test.ts
tmokmss Dec 13, 2023
2abaeba
Update deploy-stack.test.ts
tmokmss Dec 13, 2023
3cc542d
reject only when method=direct && importExistingResources==true
tmokmss Dec 14, 2023
e812eaa
Update packages/aws-cdk/README.md
tmokmss Dec 26, 2023
6e8813c
Update packages/aws-cdk/README.md
tmokmss Dec 26, 2023
dd75942
Update packages/aws-cdk/README.md
tmokmss Dec 26, 2023
8b5ea7e
Merge branch 'main' into allow_import_resources
tmokmss Dec 27, 2023
552e0eb
Merge branch 'main' into allow_import_resources
tmokmss Jan 21, 2024
8803a58
Merge branch 'main' into allow_import_resources
tmokmss Feb 3, 2024
1051e8f
Merge branch 'main' into allow_import_resources
tmokmss Feb 13, 2024
af43d96
Merge branch 'main' into allow_import_resources
SankyRed Apr 9, 2024
c8be1f5
merge
tmokmss Sep 17, 2024
8eb1549
Update packages/aws-cdk/README.md
tmokmss Sep 20, 2024
293a61f
Apply suggestions from code review
tmokmss Sep 20, 2024
ced4fb1
Update README.md
tmokmss Sep 20, 2024
5b1db10
add missing periods in docs
tmokmss Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README.md
tmokmss committed Dec 13, 2023
commit 2a6aae5c011521f63917c1b1f34121ab85348cc7
25 changes: 24 additions & 1 deletion packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
@@ -382,6 +382,29 @@ $ cdk deploy --method=prepare-change-set --change-set-name MyChangeSetName
For more control over when stack changes are deployed, the CDK can generate a
CloudFormation change set but not execute it.

#### Import existing resources
You can pass the `--import-existing-resources` flag to the `deploy` command:

```console
$ cdk deploy --import-existing-resources
```

This allows you to automatically import the resources in your template that already exist in your AWS account during CloudFormation deployments. With this feature, you can reduce the manual effort of import operations and avoid deployment failures because of naming conflicts.

To review which resources are imported or not before actually executing a change set, use `--method=prepare-change-set` flag. You can inspect the change set created by CDK from the management console or other external tools.

```console
$ cdk deploy --import-existing-resources --method=prepare-change-set
```

To enable this feature only for a specific stack, use `--exclusively` flag.

```console
$ cdk deploy --import-existing-resources --exclusively StackName
```

This parameter can only import resources that have custom names in templates. For more information, see [name type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html) in the AWS CloudFormation User Guide. To import resources that do not accept custom names, such as EC2 instances, use the `cdk import` instead. You can find more details [here](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html#API_CreateChangeSet_RequestParameters).

#### Hotswap deployments for faster development

You can pass the `--hotswap` flag to the `deploy` command:
@@ -559,7 +582,7 @@ To import an existing resource to a CDK stack, follow the following steps:
5. When `cdk import` reports success, the resource is managed by CDK. Any subsequent
changes in the construct configuration will be reflected on the resource.

You can also import existing resources by `--import-existing-resources` option of `cdk deploy` command. This parameter only works for resources that you can set custom physical names, such as S3 bucket, DynamoDB table, etc. For more information, see [`ImportResourceResources` parameter](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html#API_CreateChangeSet_RequestParameters) in AWS CloudFormation API reference.
NOTE: You can also import existing resources by `--import-existing-resources` option of `cdk deploy` command. This parameter only works for resources that you can set custom physical names, such as S3 bucket, DynamoDB table, etc. For more information, see [`ImportResourceResources` parameter](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html#API_CreateChangeSet_RequestParameters) in AWS CloudFormation API reference.

#### Limitations