We'll create a new CDK Stack, defining a DynamoDB table called "Items" that is configured to pay per request with a partition key of ID.
Here a typo in min 1:45 is dynamo.Table instead of dynamo.table
I keep getting this error when running "cdk deploy"
throw new Error('construct does not have an associated node. All constructs must extend the "Construct" base class');
anyone else having this issue?
I am also having that issue
Hey, here is an issue that should hopefully solve your problem. We will look into the validity of the course with the mismatched versions in mind. https://github.com/aws/aws-cdk/issues/20370
Yeah this tutorial is broken. I'm unable to do a 'cdk deploy' as well. This tutorial needs to be updated to be compatible with aws-cdk v2.
Solution I found was to do the following:
cdk init <app-name> --language typescript
This init builds with v2 of the aws-cdk, while the --language javascript in this tutorial defaults to v1.import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
export class NextjsDynamodbStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props);
new dynamodb.Table(this, 'Items', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
});
}
}
3. cdk bootstrap
This is needed if it's your first time to try and do cdk deploy
4. cdk deploy