0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CDKで"Argument of type 'this' is not assignable to parameter of type 'Construct'."

Last updated at Posted at 2021-03-23

なんでや

ドキュメント通りに書いてもエラー出たりした。


const ec2Instance = new ec2.CfnInstance(
  this, //ここで Argument of type 'this' is not assignable to parameter of type 'Construct'.
  'ec2Instance',
  {
    imageId:  'ami-xxxx',
    instanceType: 't3.medium',
    ...
  }
);

moduleのバージョンが違ってるのが原因

"dependencies": {
  "@aws-cdk/aws-ec2": "^1.94.1", // これと
  "@aws-cdk/core": "1.86.0", // これのバージョンが違ってるから出るっぽい
  "source-map-support": "^0.5.16"
}

@aws-cdk/coreのバージョンに合わせると幸せになれる。

"dependencies": {
  "@aws-cdk/aws-ec2": "1.86.0",
  "@aws-cdk/core": "1.86.0",
  "source-map-support": "^0.5.16"
}

インストール時にバージョンしておけば上記の問題起こらないです

npm i @aws-cdk/aws-ec2@1.86.0

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?