I seem to be facing an issue while trying to create a new instance of the CloudFrontWebDistribution
using aws-cdk v1.7
. The compiler is showing some dissatisfaction with the construct I provided.
import { Stack, StackProps, Construct, App } from '@aws-cdk/core';
import { CloudFrontWebDistribution } from '@aws-cdk/aws-cloudfront';
export class MyCloudFrontStack extends Stack {
constructor(scope: Construct, id: string, CloudFrontStackParameters, props?: StackProps) {
super(scope, id, props);
const env = parameters.environment.toLowerCase();
const webDistributionConfigs = { // configurations here... };
this.cloudFrontWebDistrubtion = new CloudFrontWebDistribution(scope, id, webDistributionConfigs); // encountering typescript errors related to the scope variable
}
}
The TypeScript compiler is specifically pointing out a problem with the scope
variable that's being passed into the constructor of CloudFrontWebDistribution
.
Argument of type 'import("c:/Users/me/node_modules/@aws-cdk/core/lib/construct").Construct' is not assignable to parameter of type 'import("c:/Users/me/node_modules/@aws-cdk/aws-lambda/node_modules/@aws-cdk/core/lib/construct").Construct'. Types of property 'node' are incompatible. Property '_defaultChild' is missing in type 'import("c:/Users/me/node_modules/@aws-cdk/core/lib/construct").ConstructNode' but required in type 'import("c:/Users/me/node_modules/@aws-cdk/aws-lambda/node_modules/@aws-cdk/core/lib/construct").ConstructNode'.ts(2345) construct.d.ts(61, 13): '_defaultChild' is declared here.
Could it be a misuse of types on my end? Any suggestions on where I might have gone wrong?