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(all): migrate to CDKv2 #738

Merged
merged 1 commit into from
Jul 28, 2022
Merged

Conversation

ddneilson
Copy link
Contributor

  • Migrates the RFDK library, examples, and integration tests to CDKv2.

BREAKING CHANGE: This change migrates the RFDK to be based on CDK v2.
All apps that use the RFDK will have to be migrated to CDKv2 as well.
To update your app, follow the CDK's migration guide at:
https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html


Some notes:

  1. Most of the changes are pretty superficial. Migrating application code from CDKv1 to CDKv2 really just entails changing imports, and updating any uses of construct properties that were deprecated in v1 and removed in v2. We've been pretty good about staying on top of updating uses of deprecated properties, so it was mostly import updates for us.
  2. CDKv2 removed the @aws-cdk/asserts module that we were using for unit tests and replaced it with aws-cdk-lib/assertions. This was a major change. Syntax and functionality changed. The CDK team provides a migration guide (here: https://github.com/aws/aws-cdk/blob/v1-main/packages/@aws-cdk/assertions/MIGRATING.md ) that includes a migration script; the script got about 70% of the way, and the rest had to be done manually. The biggest change was that once you've asserted properties of a stack/app in a test then the state of the stack is baked-in at that time. So, you cannot, say, assert a property, then add something to the stack, and then assert a new property -- the second assertion will fail as it will be asserting against the stack pre-addition; this change required retooling some unit tests.
  3. I cleaned up the integration tests a bit; mostly making sure that the test logs were more find-able, and fixing a resource leak (mongoDB test was leaking an EBS volume on every run).
  4. The migration is to CDK v2.33.0 as that is the current version as of right now.

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

@jericht jericht self-requested a review July 27, 2022 19:27
}));
});

test('creates an asset', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: This test is not possible with the under-the-hood changes introduced in CDKv2. Fortunately, this is tested, in a way, by the tests that look at UserData; the CDK now generates the file sha256 before synthesis, so file hashes are directly embedded into UserData in both the rendered stack and when directly rendering the UserData string from the contruct.

Copy link
Contributor

@kozlove-aws kozlove-aws left a comment

Choose a reason for hiding this comment

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

Great job, especially with making all tests work.
Just a couple moment I want to clarify.

jericht
jericht previously approved these changes Jul 28, 2022
Copy link
Contributor

@jericht jericht left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for doing this migration. Just found a couple bits of commented out code, but not holding back the PR for it

Comment on lines 342 to 343
//const res = Template.fromStack(stack).findResources('AWS::IAM::Policy', Match.anyValue);
//expect(res).toBe({ foo: 'bar' });
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drat. Will fix. Thanks!

Tags,
} from '@aws-cdk/core';
} from 'aws-cdk-lib/aws-iam';
//import { ArtifactMetadataEntryType } from '@aws-cdk/cloud-assembly-schema';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drat. Will fix. Thanks!

* Migrates the RFDK library, examples, and integration tests to CDKv2.

BREAKING CHANGE: This change migrates the RFDK to be based on CDK v2.
All apps that use the RFDK will have to be migrated to CDKv2 as well.
To update your app, follow the CDK's migration guide at:
https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html
@ddneilson ddneilson merged commit 7c06857 into aws:mainline Jul 28, 2022
@ddneilson ddneilson deleted the migrate_cdk_v2 branch July 28, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants