(aws_elasticloadbalancingv2): TargetGroupListenerAction.bind not called when chained with another ListenerAction
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### What is the problem?
I am trying to add a default action to my Application Listener which uses OIDC authentication before forwarding to a target group. This is the code snippet copied exactly from the CDK documentation:
```
declare const listener: elbv2.ApplicationListener;
declare const myTargetGroup: elbv2.ApplicationTargetGroup;
listener.addAction('DefaultAction', {
action: elbv2.ListenerAction.authenticateOidc({
authorizationEndpoint: 'https://example.com/openid',
// Other OIDC properties here
clientId: '...',
clientSecret: SecretValue.secretsManager('...'),
issuer: '...',
tokenEndpoint: '...',
userInfoEndpoint: '...',
// Next
next: elbv2.ListenerAction.forward([myTargetGroup]),
}),
});
```
However, since `addAction` is not called directly with the TargetGroupListenerAction, the listener never calls `bind` on the Forward action, and so the target group [is not registered](https://github.com/aws/aws-cdk/blob/a4387bd1440c3167191c986dd90e1f2ec2e28036/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-action.ts#L445) with the listener.
`bind` is [only called on the action](https://github.com/aws/aws-cdk/blob/a4387bd1440c3167191c986dd90e1f2ec2e28036/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts#L458) directly passed to `addAction`, and the OIDC Listener Action has the default no-op [bind implementation](https://github.com/aws/aws-cdk/blob/a4387bd1440c3167191c986dd90e1f2ec2e28036/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-action.ts#L178) without calling bind on the "next" action.
This doesn't seem to be a problem for deploying the application listener with the expected set of actions. However, if I want to reference this target group elsewhere in my CDK, for example to create a dashboard with metrics, CDK [throws an error](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts#L242) due to no listener being registered with the target group.
### Reproduction Steps
Follow example for creating OIDC default action chained with a forward action https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts#L242.
Call `myTargetGroup.metric(...)` after doing so.
### What did you expect to happen?
Target group is registered with the Application Listener and I can use the `TargetGroup.metric` convenience method.
### What actually happened?
`TargetGroup.metric` throws an error stating it is not bound to an application load balancer/listener.
### CDK CLI Version
1.139.0
### Framework Version
_No response_
### Node.js Version
12.19.0
### OS
macOS
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start in packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts and application-listener-action.ts, focusing on the bind calls and the chained OIDC and forward actions. Reproduce the issue with the documented example, then verify that myTargetGroup.metric(...) no longer reports the target group as unbound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100