Description of the bug Can't use imported lambda with ELBv2
This is similar to #8597 which was closed due to similar bugs in Lambda but ElasticLoadBalancingv2 module still needs to fix their part
Reproduction Steps
This piece of code will produce the error below
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: false
});
const listener = lb.addListener('Listener', {
port: 80,
});
const fn = lambda.Function.fromFunctionArn(this, 'myFunction', functionARN)
listener.addTargets('Target', {
port: 80,
targets: [new targets.LambdaTarget(fn)]
});
// @aws-cdk/aws-elasticloadbalancingv2-targets.LambdaTarget
const lambdaTarget = new targets.LambdaTarget(fn);
new lambda.CfnPermission(this, 'MyRule_MyLambda_InvokePermission', {
action: 'lambda:InvokeFunction',
functionName: fn.functionArn,
principal: 'elasticloadbalancing.amazonaws.com',
sourceArn: listener.listenerArn
})
listener.addTargets('Target', {
port: 80,
targets: [lambdaTarget]
})
listener.connections.allowDefaultPortFromAnyIpv4('test');
What actually happened?
when running cdk synth I get the following error
No child with id: 'InvokeServicePrincipal(elasticloadbalancing.amazonaws.com)'
/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/@aws-cdk/core/lib/private/synthesis.ts:151
throw new Error(`Validation failed with the following errors:\n ${errorList}`);
^
Error: Validation failed with the following errors:
[RootEndpointStack/LB/Listener] Listener needs at least one default action or target group (call addTargetGroups or addAction)
at validateTree (/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/@aws-cdk/core/lib/private/synthesis.ts:151:11)
at Object.synthesize (/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/@aws-cdk/core/lib/private/synthesis.ts:25:5)
at App.synth (/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/@aws-cdk/core/lib/stage.ts:175:23)
at process.App.process.once (/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/@aws-cdk/core/lib/app.ts:112:45)
at Object.onceWrapper (events.js:286:20)
at process.emit (events.js:198:13)
at process.EventEmitter.emit (domain.js:448:20)
at process.emit (/home/ec2-user/environment/monolithic-modernization-lab/root-endpoint/node_modules/source-map-support/source-map-support.js:495:21)
at process.topLevelDomainCallback (domain.js:126:23)
Environment
- CLI Version : 1.64.1 (build 14a8c8d)
- **Framework Version: 1.64.1 **
- Node.js Version: v10.19.0
- OS : Linux 4.14.165-103.209.amzn1.x86_64
- Language (Version): TypeScript
Other
Removing the lambda.CfnPermission produces the same issue.
Issue has been first reported in Bug Report 8597 - That report seems to be closed due to fixes in Lambda, but the aws-elasticloadbalancingv2 module still seems to be doing something else.
This is 🐛 Bug Report
Description of the bug Can't use imported lambda with ELBv2
This is similar to #8597 which was closed due to similar bugs in Lambda but ElasticLoadBalancingv2 module still needs to fix their part
Reproduction Steps
This piece of code will produce the error below
What actually happened?
when running cdk synth I get the following error
Environment
Other
Removing the lambda.CfnPermission produces the same issue.
Issue has been first reported in Bug Report 8597 - That report seems to be closed due to fixes in Lambda, but the aws-elasticloadbalancingv2 module still seems to be doing something else.
This is 🐛 Bug Report