Skip to content

Commit 7393b3c

Browse files
committed
wip
1 parent 23b378d commit 7393b3c

File tree

1 file changed

+15
-38
lines changed

1 file changed

+15
-38
lines changed

packages/aws-cdk-lib/aws-ecs/lib/alternate-target-configuration.ts

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,42 @@ import * as iam from '../../aws-iam';
88
export abstract class ListenerRuleConfiguration {
99
/**
1010
* Use an Application Load Balancer listener rule
11-
* @param rule The application listener rule
12-
* @param testRule Optional test listener rule for blue/green deployments
1311
*/
14-
public static applicationListenerRule(
15-
rule: elbv2.ApplicationListenerRule,
16-
testRule?: elbv2.ApplicationListenerRule,
17-
): ListenerRuleConfiguration {
18-
return new ApplicationListenerRuleConfiguration(rule, testRule);
12+
public static applicationListenerRule(rule: elbv2.ApplicationListenerRule): ListenerRuleConfiguration {
13+
return new ApplicationListenerRuleConfiguration(rule);
1914
}
2015

2116
/**
2217
* Use a Network Load Balancer listener
23-
* @param listener The network listener
24-
* @param testListener Optional test listener for blue/green deployments
2518
*/
26-
public static networkListener(
27-
listener: elbv2.NetworkListener,
28-
testListener?: elbv2.NetworkListener,
29-
): ListenerRuleConfiguration {
30-
return new NetworkListenerConfiguration(listener, testListener);
19+
public static networkListener(listener: elbv2.NetworkListener): ListenerRuleConfiguration {
20+
return new NetworkListenerConfiguration(listener);
3121
}
3222

3323
/**
3424
* @internal
3525
*/
3626
public abstract readonly _listenerArn: string;
37-
38-
/**
39-
* @internal
40-
*/
41-
public abstract readonly _testListenerArn?: string;
4227
}
4328

4429
class ApplicationListenerRuleConfiguration extends ListenerRuleConfiguration {
45-
constructor(
46-
private readonly rule: elbv2.ApplicationListenerRule,
47-
private readonly testRule?: elbv2.ApplicationListenerRule,
48-
) {
30+
constructor(private readonly rule: elbv2.ApplicationListenerRule) {
4931
super();
5032
}
5133

5234
public get _listenerArn(): string {
5335
return this.rule.listenerRuleArn;
5436
}
55-
56-
public get _testListenerArn(): string | undefined {
57-
return this.testRule?.listenerRuleArn;
58-
}
5937
}
6038

6139
class NetworkListenerConfiguration extends ListenerRuleConfiguration {
62-
constructor(
63-
private readonly listener: elbv2.NetworkListener,
64-
private readonly testListener?: elbv2.NetworkListener,
65-
) {
40+
constructor(private readonly listener: elbv2.NetworkListener) {
6641
super();
6742
}
6843

6944
public get _listenerArn(): string {
7045
return this.listener.listenerArn;
7146
}
72-
73-
public get _testListenerArn(): string | undefined {
74-
return this.testListener?.listenerArn;
75-
}
7647
}
7748

7849
/**
@@ -125,6 +96,12 @@ export interface AlternateTargetOptions {
12596
* @default - a new role will be created
12697
*/
12798
readonly role?: iam.IRole;
99+
100+
/**
101+
* The test listener configuration
102+
* @default - none
103+
*/
104+
readonly testListener?: ListenerRuleConfiguration;
128105
}
129106

130107
/**
@@ -157,8 +134,8 @@ export class AlternateTarget implements IAlternateTarget {
157134
this.props.productionListener._listenerArn,
158135
];
159136

160-
if (this.props.productionListener._testListenerArn) {
161-
resources.push(this.props.productionListener._testListenerArn);
137+
if (this.props.testListener) {
138+
resources.push(this.props.testListener._listenerArn);
162139
}
163140

164141
const roleId = `${this.id}Role`;
@@ -173,7 +150,7 @@ export class AlternateTarget implements IAlternateTarget {
173150
alternateTargetGroupArn: this.props.alternateTargetGroup.targetGroupArn,
174151
roleArn: role.roleArn,
175152
productionListenerRule: this.props.productionListener._listenerArn,
176-
testListenerRule: this.props.productionListener._testListenerArn,
153+
testListenerRule: this.props.testListener?._listenerArn,
177154
};
178155

179156
return config;

0 commit comments

Comments
 (0)