I am trying simple CDK tutorial, however I bumped into some error.
My code is simply like this,
Argument of type 'App' is not assignable to parameter of type 'Construct'.
Type 'App' is missing the following properties from type 'Construct': onValidate, onPrepare, onSynthesize, validate, and 2 more.
7 new HelloCdkStack(app, 'HelloCdkStack', {
Somehow this error comes, but in a few tutorials using cdk.App()
. Why does this error happens??
import * as cdk from "@aws-cdk/core";
import {Table, AttributeType} from "@aws-cdk/aws-dynamodb";
export class HelloCdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new Table(this, "items", {
partitionKey: {
name: "itemId",
type: AttributeType.STRING,
},
tableName: "items",
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});
// The code that defines your stack goes here
// example resource
// const queue = new sqs.Queue(this, 'HelloCdkQueue', {
// visibilityTimeout: cdk.Duration.seconds(300)
// });
}
}
const app = new cdk.App();
new HelloCdkStack(app, "HelloCdkStack");
app.synth();