Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(elbv2): connections not created for chained listener actions #21939

Merged
merged 3 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ export class ListenerAction implements IListenerAction {
* Called when the action is being used in a listener
*/
public bind(scope: Construct, listener: IApplicationListener, associatingConstruct?: IConstruct) {
// Empty on purpose
Array.isArray(scope);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly don't understand what this was doing.

Array.isArray(listener);
Array.isArray(associatingConstruct);
this.next?.bind(scope, listener, associatingConstruct);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Metric } from '@aws-cdk/aws-cloudwatch';
import * as ec2 from '@aws-cdk/aws-ec2';
import { describeDeprecated, testDeprecated } from '@aws-cdk/cdk-build-tools';
import * as cdk from '@aws-cdk/core';
import { SecretValue } from '@aws-cdk/core';
import * as constructs from 'constructs';
import * as elbv2 from '../../lib';
import { FakeSelfRegisteringTarget } from '../helpers';
Expand Down Expand Up @@ -261,6 +262,53 @@ describe('tests', () => {
});
});

test('bind is called for all next targets', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc });
const listener = lb.addListener('Listener', { port: 80 });
const fake = new FakeSelfRegisteringTarget(stack, 'FakeTG', vpc);
const group = new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
port: 80,
targets: [fake],
});

// WHEN
listener.addAction('first-action', {
action: elbv2.ListenerAction.authenticateOidc({
next: elbv2.ListenerAction.forward([group]),
issuer: 'dummy',
clientId: 'dummy',
clientSecret: SecretValue.unsafePlainText('dummy'),
tokenEndpoint: 'dummy',
userInfoEndpoint: 'dummy',
authorizationEndpoint: 'dummy',
}),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroupIngress', {
IpProtocol: 'tcp',
Description: 'Load balancer to target',
FromPort: 80,
ToPort: 80,
GroupId: {
'Fn::GetAtt': [
'FakeTGSG50E257DF',
'GroupId',
],
},
SourceSecurityGroupId: {
'Fn::GetAtt': [
'LBSecurityGroup8A41EA2B',
'GroupId',
],
},
});
});

testDeprecated('Can implicitly create target groups with and without conditions', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down