Import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
export class AwsCdkStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const newCluster = new eks.Cluster(this, 'Dbaas-eks-cluster_cdk', {
version: eks.KubernetesVersion.V1_21,
defaultCapacity: 5,
defaultCapacityInstance: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.SMALL),
Here is my package.json
"name": "aws-cdk",
"version": "0.1.0",
"bin": {
"aws-cdk": "bin/aws-cdk.js"
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
"peerDependencies": {
"aws-cdk-lib": "^2.8.0",
"constructs": "^10.0.36"
"devDependencies": {
"@aws-cdk/assert": "^2.8.0",
"@aws-cdk/aws-appsync-alpha": "^2.8.0-alpha.0",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.8",
"aws-cdk-lib": "^2.8.0",
"constructs": "^10.0.36",
"esbuild": "^0.14.11",
"jest": "^27.4.7",
"ts-jest": "^27.0.2",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"dependencies": {
"@aws-cdk/aws-ec2": "^1.161.0",
"@pulumi/aws": "^5.9.2",
"@pulumi/awsx": "^0.40.0"
Expected Behavior
It shouldn't throw an error
Current Behavior
It is throwing the below error
Argument of type 'undefined' is not assignable to parameter of type 'Construct'.ts
Reproduction Steps
If I run the mentioned TS file with the current package.json file in Visual Studio Code, I'm getting error
Possible Solution
I suppose my dependencies might not be configured correctly i.e. I'm missing something with my package.json dependencies. Went through a couple of issues, but couldn't find a solution
Additional Information/Context
No response
CDK CLI Version
2.29.1 (build c42e961)
Framework Version
No response
Node.js Version
v18.4.0
MacOS
Language
Typescript
Language Version
TypeScript (4.7.4)
Other information
No response
@raikarjayani the cluster needs to be created in the Stack scope. Like this:
Import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
export class AwsCdkStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const newCluster = new eks.Cluster(this, 'Dbaas-eks-cluster_cdk', {
version: eks.KubernetesVersion.V1_21,
defaultCapacity: 5,
defaultCapacityInstance: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.SMALL),
});
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
and removed
closing-soon
This issue will automatically close in 4 days unless further comments are made.
labels
Jul 3, 2022
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
guidance
Question that needs advice or information.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.