Skip to content

chore: aws cdk v2 migration troubleshooting #4990

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

Merged
merged 24 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Binary file added public/images/ts-guide-cdk-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/ts-guide-cdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/directory/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,11 @@ const directory = {
migration: {
title: 'Migration & Backwards Compatibility',
items: [
{
title: 'AWS CDK v1 to v2 migration',
route: '/cli/migration/aws-cdk-migration',
filters: []
},
{
title: 'Lazy Loading and Custom Selection Set',
route: '/cli/migration/lazy-load-custom-selection-set',
Expand Down
44 changes: 44 additions & 0 deletions src/pages/cli/migration/aws-cdk-migration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const meta = {
title: `AWS CDK v1 to v2 migration`,
description: ``,
};

<Callout>
AWS CDK version should match the CDK version that cli-extensibility-helper package uses as a dependency in `amplify/backend/custom/customResourceName/package.json`.


You can verify the `aws-cdk-lib` version that [`@aws-amplify/cli-extensibility-helper`](https://www.npmjs.com/package/@aws-amplify/cli-extensibility-helper?activeTab=explore) uses in the `amplify/backend/package.json` file.

</Callout>

[AWS Cloud Development Kit (CDK) version 1](https://docs.aws.amazon.com/cdk/v1/guide/home.html) that Amplify CLI uses under the hood has entered maintenance on June 1, 2022 with end of support date scheduled on June 1, 2023.
Amplify CLI v11 and above uses CDK v2 to help you move away from deprecated CDK as well as unblock new features that won’t be added to version 1 of CDK.
To learn more about AWS CDK Migration, visit [Migrating to V2](https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html)
## When to migrate
During deployment, Amplify CLI searches for AWS CDK v1 dependencies in your project and if found, Amplify CLI prints a warning to migrate to AWS CDK v2.

```console
We detect you are using CDK v1 with custom stacks and overrides. AWS CDK v1 has entered maintenance mode on June 1, 2022

Impacted files.
- amplify/backend/package.json
Upgrade '@aws-amplify/cli-extensibility-helper' to latest version ^3.0.0

- amplify/backend/custom/<resource-name1>/package.json
- amplify/backend/custom/<resource-name2>/package.json
Comment on lines +23 to +28
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Impacted files.
- amplify/backend/package.json
Upgrade '@aws-amplify/cli-extensibility-helper' to latest version ^3.0.0
- amplify/backend/custom/<resource-name1>/package.json
- amplify/backend/custom/<resource-name2>/package.json
Impacted files:
- `amplify/backend/package.json`
Upgrade `@aws-amplify/cli-extensibility-helper` to latest version (`^3.0.0`)
- `amplify/backend/custom/<resource-name-1>/package.json`
- `amplify/backend/custom/<resource-name-2>/package.json`

for readability

Copy link
Contributor

Choose a reason for hiding this comment

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

well, I now realize this is in a fenced code block and is likely the output from the CLI


Follow this guide here: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html
```

## How do I migrate?

If an Amplify project using `amplify override <category>` or `amplify add custom` was deployed with an Amplify CLI version prior to 11.0.0, then you need to follow the steps below to migrate:
1. For projects using `amplify overrides <category>`:
Upgrade `@aws-amplify/cli-extensibility-helper` to version `^3.0.0` in `amplify/backend/package.json`
2. For projects using `amplify add custom`:
Update `package.json` for `custom` categories in `amplify/backend/custom/<custom-resource-name>/package.json` as shown below:

![Amplify overrides warning](/images/ts-guide-cdk-package.png)
And update `amplify/backend/custom/<custom-resource-name>/cdk-stack.ts` for `custom` categories as shown below:

![Amplify custom warning](/images/ts-guide-cdk.png)
6 changes: 6 additions & 0 deletions src/pages/cli/project/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ Amplify currently doesn't support automatic data migration. If the data in the o
If you have previously deployed an application using GraphQL transformer V1 and have decided to migrate to GraphQL transformer V2, go through the [GraphQL transformer migration documentation](/cli/migration/transformer-migration/#changes-that-amplify-cli-will-auto-migrate-for-you) to understand the impact of the migration on the schema directives and limitations prior to updating.
You can confirm the version of the GraphQL transformer using the `amplify status` command. You can also inspect the `transformerversion` feature flag in `${project-root}/amplify/cli.json`, to confirm.

### Version 11 migration from AWS CDK V1 to V2
If the Amplify project has been deployed with an Amplify CLI version prior to 11.0.0 that utilizes overrides or custom resources, go through the [AWS CDK migration documentation](/cli/migration/aws-cdk-migration/).
If the problem persists, [create an issue](https://github.com/aws-amplify/amplify-cli/issues/new?assignees=&labels=pending-triage&template=1.bug_report.yaml)

[Learn more about migrating to CDK v2](https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html)

### Local testing
Test schema changes and business logic as much as you can prior to deployment. The `amplify mock` command allows validation of your cloud dependencies locally. Follow the mock testing examples in [Advanced workflows documentation](/cli/usage/mock/) to dive deeper.

Expand Down