😡
AmplifyのCustomリソースで'cdkStack' is missing the following propertiesが出たら
現象
amplify add customでCDKを選んで作業を始めたばかりなのに、いきなり以下のようなエラーが発生することがあります。
Argument of type 'this' is not assignable to parameter of type 'Stack'. Type 'cdkStack' is missing the following properties from type 'Stack': _suppressTemplateIndentation, _terminationProtection
現象の発生原因
-
AmplifyHelpers.addResourceDependencyが参照するaws-cdk-lib -
cdk-stack.tsが参照するaws-cdk-lib
のバージョンが違うので私の環境ではおきていました
解決手順
-
該当の
package.jsonファイルに記載されているaws-cdk-libのバージョンを確認する。-
amplify/backend/custom/<custom-resource-name>/package.json-
AmplifyHelpers.addResourceDependencyが参照するaws-cdk-lib
-
-
amplify/backend/custom/<custom-resource-name>/node_modules/@aws-amplify/amplify-cli-core/package.json-
cdk-stack.tsが参照するaws-cdk-lib
-
-
-
amplify/backend/custom/<custom-resource-name>/package.jsonのバージョンを修正して、2つのファイルのバージョンを一致させる。cd amplify/backend/custom/<custom-resource-name> rm -rf node_modules package-lock.json npm i
これで問題が解決しました。
Discussion