According to Amplify documentation and this official blog post, it is possible to export infrastructures from Amplify then import into CDK. However, I try with CDK V2 and it does not work. I got error when installing npm i @aws-amplify/cdk-exported-backend@latest. CDK V2 Construct is not compatible with the Construct in aws-amplify/cdk-exported-backend, I think. So how to export Amplify infrastructure to CDK V2? Thank you!
- Here is my package.json of CDK
{
"name": "amplify-export-cdk",
"version": "0.1.0",
"bin": {
"amplify-export-cdk": "bin/amplify-export-cdk.js"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
},
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "10.17.27",
"jest": "^26.4.2",
"ts-jest": "^26.2.0",
"aws-cdk": "2.18.0",
"ts-node": "^9.0.0",
"typescript": "~3.9.7"
},
"dependencies": {
"aws-cdk-lib": "2.18.0",
"constructs": "^10.0.0",
"source-map-support": "^0.5.16"
}
}
- Here is errors when installing
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: amplify-export-cdk@0.1.0
npm ERR! Found: constructs@10.0.108
npm ERR! node_modules/constructs
npm ERR! constructs@"^10.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer constructs@"^3.2.27" from @aws-amplify/cdk-exported-backend@0.0.5
npm ERR! node_modules/@aws-amplify/cdk-exported-backend
npm ERR! @aws-amplify/cdk-exported-backend@"0.0.5" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.