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

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)