Argument of type 'App' is not assignable to parameter of type 'Construct'
Solution 1:
Go to the cdk_primer-stack.ts
file and fix the import of your core SDK from import * as cdk from 'aws-cdk-lib';
to import * as cdk from '@aws-cdk/core';
The problem is that you are using a different version of CDK Core in your file than imported in cdk_primer-stack.ts
.
Solution 2:
In AWS CDK 1.x, imports were done using import were made from '@aws-cdk/core'. This was changed in CDK 2.x, in which imports are made from aws-cdk-lib package.
Many tutorials would still use CDK 1.x whereas starter code for CDK uses 2.x. This is why you have discrepancy because the code for App initialization would say use the newer module whereas the tutorials would assume you'd do this the old way.
To fix this,
- update your stack file to use the new one:
import { Stack, StackProps } from 'aws-cdk-lib';
- update your app initialization file to use old one:
import * as cdk from '@aws-cdk/core';
Documentation for AWS CDK 2.x: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib-readme.html
Documentation for AWS CDK 1.x: https://docs.aws.amazon.com/cdk/api/v1/docs/aws-construct-library.html