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

Conversation

tmokmss
Copy link
Contributor

@tmokmss tmokmss commented Feb 13, 2024

Issue # (if applicable)

Closes #28060.

Reason for this change

This feature allows to automatically import exsting resources with the same physical name, such as S3 bucket, DDB table, etc, during a CFn deployment.

Because resource import is a vital feature for CDK users e.g. to refactor a construct tree, cdk migrate, etc, it would benefit many potential users if cdk natively support it.

Description of changes

This PR adds a CLI option --import-exsting-resources: boolean to cdk deploy command and pass it to createChangeSet API call.

Description of how you validated changes

Added a cli integ test.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team February 13, 2024 07:21
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Feb 13, 2024
@mergify mergify bot dismissed stale reviews from HBobertz and comcalvi September 20, 2024 00:51

Pull request has been modified.

Co-authored-by: Hogan Bobertz <[email protected]>
Co-authored-by: Calvin Combs <[email protected]>
@tmokmss
Copy link
Contributor Author

tmokmss commented Sep 20, 2024

@HBobertz @comcalvi

Thanks! I addressed all the comments from you :)

It's unclear if this flag works with IMPORT type changesets. Those changesets should not create anything, but autoimport likely needs a CREATE to import the resource...maybe IMPORT changesets recognize that?

As far as I tested, CFn decides whether a resource is created or imported when we create a changeset. If a resource will be imported, the changeset type for the resource will become IMPORT, and if not, it wil become CREATE.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 20, 2024
Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending a CLI test run.

@tmokmss
Copy link
Contributor Author

tmokmss commented Sep 26, 2024

@comcalvi Thanks! Just for confirmation, have you triggered a cli test? I see the request is still pending. (not really sure how it works though)
image

@tmokmss
Copy link
Contributor Author

tmokmss commented Oct 1, 2024

@comcalvi Hi, let me know the integ-test result when you get a chance :) I guess I don't have access to it.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 5b1db10
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@jiayiwang7 jiayiwang7 requested review from kaizencc and removed request for kaizencc December 16, 2024 17:58
@kaizencc
Copy link
Contributor

kaizencc commented Dec 26, 2024

@tmokmss I mean to help you get this PR across the finish line. first step was to fix the merge conflicts, which are a little bit difficult. I did it locally, but I'm not able to push to this branch. Is there any reason that is the case on your end? It makes me sad because I spent some time trying to fix up the branch for you :(.

error: Authentication error: Authentication required: You must have push access to verify locks
error: failed to push some refs to 'https://github.com/tmokmss/aws-cdk.git'

i can also start a new branch and we can go from there but im first wondering if there's something quick you can do on your end to ensure that i have push access to your fork.

@tmokmss
Copy link
Contributor Author

tmokmss commented Dec 26, 2024

Hi @kaizencc, thanks for working on this and sorry I didn't realize it was in conflict.

I confirmed that `Allow edits and access to secrets by maintainers' is checked, so I think you should be able to push commits. Not sure about the error, but if this is a blocker, it's okay to create a new branch and PR. I'm excited to see this finally merged :)

@kaizencc
Copy link
Contributor

@tmokmss i can't figure it out :/ so i just went ahead and created a new PR to main from your PR. I think you'll still get credit, but i also want to add a coauthor message to the PR description just in case. I'll need an email address associated to your github account to make that happen though.

@tmokmss
Copy link
Contributor Author

tmokmss commented Dec 28, 2024

@kaizencc thanks for your kindness! You can use this address:
[email protected]

@kaizencc
Copy link
Contributor

kaizencc commented Jan 2, 2025

#32676 was merged

@kaizencc kaizencc closed this Jan 2, 2025
Copy link

github-actions bot commented Jan 2, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/do-not-close The PR linter will not close this PR while this label is present pr-linter/exempt-integ-test The PR linter will not require integ test changes star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: support CloudFormation simplified resource import
9 participants