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

chore(migrate): enable import of resources on apps created from cdk migrate #28678

Merged
merged 5 commits into from
Jan 12, 2024

Conversation

TheRealAmazonKendra
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra commented Jan 12, 2024

Apps generated from cdk migrate with resources that aren't already part of a stack will (soon) create a migrate.json file. This file contains the list of resources that should be imported upon creation of the new app.

If this file is present and the source is either localfile or the ARN environment matches the deployment environment, running cdk deploy will:

  1. Create a new stack and import the resources listed in migrate.json.
  2. Apply outputs and CDKMetadata through a normal deployment.

Note: localfile is a placeholder value so that we can run integration tests on this change. Once some of the other in-progress work is finished, this will be updated.


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

@github-actions github-actions bot added the p2 label Jan 12, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 12, 2024 01:38
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 12, 2024
@TheRealAmazonKendra TheRealAmazonKendra force-pushed the TheRealAmazonKendra/import-migrate-resources branch from 2d3bee2 to fea7a97 Compare January 12, 2024 01:39
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jan 12, 2024
@TheRealAmazonKendra TheRealAmazonKendra force-pushed the TheRealAmazonKendra/import-migrate-resources branch from fea7a97 to d6af519 Compare January 12, 2024 01:45
@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(migrate): enable import of resources on apps created from cdk migrate chore(migrate): enable import of resources on apps created from cdk migrate Jan 12, 2024
@TheRealAmazonKendra TheRealAmazonKendra marked this pull request as draft January 12, 2024 02:07
@TheRealAmazonKendra TheRealAmazonKendra force-pushed the TheRealAmazonKendra/import-migrate-resources branch from d6af519 to deebef5 Compare January 12, 2024 03:56
@TheRealAmazonKendra TheRealAmazonKendra force-pushed the TheRealAmazonKendra/import-migrate-resources branch from deebef5 to 0b06515 Compare January 12, 2024 08:52
@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.

@TheRealAmazonKendra TheRealAmazonKendra marked this pull request as ready for review January 12, 2024 20:27
}
}

private async tryGetResources(migrateDeployment: ResourceImporter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we swap the order of tryGetResources and performResourceMigration? performResourceMigration is called by the public function, so it should be above tryGetResources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

* to add back in any outputs and the CDKMetadata.
*/
private async tryMigrateResources(stacks: StackCollection, options: DeployOptions): Promise<void> {
const stack = stacks.stackArtifacts[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the other stacks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CDK migrate only creates one stack. It is not compatible with multiple stacks at this time.

@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Jan 12, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 12, 2024 21:59

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jan 12, 2024

await this.performResourceMigration(migrateDeployment, resourcesToImport, options);

fs.rmSync('migrate.json');
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. i want to check that you mean to remove migrate.json after consuming it.
  2. why does this function "deserve" to remove this file? it seems like an unnecessary side effect of a function named tryMigrateResources. Is this the place to govern the lifecycle of that file?

This is a non-blocking comment. I don't have the full picture of migrate, just want to call attention to this and if there's no problem, then ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent here was to make deployment after using cdk migrate to generate an app zero touch, or as close to it as possible. CDK migrate generates this file that contains all the import data needed. So, the attempt at an import is only made when this file is present. Since the import only needs to happen on the first deployment, it deletes it at the end so that future deployments are not of the import type.

Copy link
Contributor

mergify bot commented Jan 12, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 811ec58 into main Jan 12, 2024
11 of 12 checks passed
@mergify mergify bot deleted the TheRealAmazonKendra/import-migrate-resources branch January 12, 2024 23:28
Copy link
Contributor

mergify bot commented Jan 12, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants