AWS CDK error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. when importing a resource
error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
This might be a simple one and still, it took me some time to realise what's up here. In my case I was importing an existing Loadbalancer into my CDK app:
const lb = new ApplicationLoadBalancer.fromApplicationLoadBalancerAttributes(this, 'ALB', {
loadBalancerArn: ssm.StringParameter.valueForStringParameter(this, '/APP/AlbArn'),
securityGroupId: SECURITY_GROUP_ID
});
The solution is as simple as it gets, its not a new resource but importing an existing resource. So instead of defining the loadbalancer as a new resources with:
const lb = new ApplicationLoadBalancer....
Just remove the new and you should be good to go.
const lb = ApplicationLoadBalancer.fromApplicationLoadBalancerAttributes(this, 'ALB', {
loadBalancerArn: ssm.StringParameter.valueForStringParameter(this, '/APP/AlbArn'),
securityGroupId: SECURITY_GROUP_ID
});
Hope that helps! If not, a great place to ask for help is the CDK.dev slack channel. A huge community that will gladly try to help you with your specific problem.