@@ -211601,6 +211601,7 @@ var updateListener_awaiter = (undefined && undefined.__awaiter) || function (thi
211601211601
211602211602function updateListener(inputs, targetEnv) {
211603211603 return updateListener_awaiter(this, void 0, void 0, function* () {
211604+ const ports = new Set(inputs.ports);
211604211605 const { EnvironmentResources } = yield ebClient.send(new dist_cjs.DescribeEnvironmentResourcesCommand({
211605211606 EnvironmentId: targetEnv.EnvironmentId,
211606211607 }));
@@ -211621,7 +211622,7 @@ function updateListener(inputs, targetEnv) {
211621211622 .then(({ TargetGroups }) => {
211622211623 const map = {};
211623211624 for (const { Port, TargetGroupArn } of TargetGroups) {
211624- if (inputs. ports.includes (Port)) {
211625+ if (ports.has (Port)) {
211625211626 map[Port] = TargetGroupArn;
211626211627 }
211627211628 }
@@ -211631,17 +211632,21 @@ function updateListener(inputs, targetEnv) {
211631211632 const { Listeners } = yield elbClient.send(new client_elastic_load_balancing_v2_dist_cjs.DescribeListenersCommand({
211632211633 LoadBalancerArn: EnvironmentResources.LoadBalancers[0].Name,
211633211634 }));
211634- yield Promise.all(inputs.ports.map((port) => elbClient.send(new client_elastic_load_balancing_v2_dist_cjs.ModifyListenerCommand({
211635- ListenerArn: Listeners.find(({ Port }) => Port === port).ListenerArn,
211636- DefaultActions: [
211637- {
211638- Type: "forward",
211639- TargetGroupArn: targetGroupArn ||
211640- mapPortToTargetGroup[port] ||
211641- mapPortToTargetGroup[inputs.ports[0]],
211642- },
211643- ],
211644- }))));
211635+ yield Promise.all(Listeners.map(({ Port, ListenerArn }) => {
211636+ if (ports.has(Port)) {
211637+ return elbClient.send(new client_elastic_load_balancing_v2_dist_cjs.ModifyListenerCommand({
211638+ ListenerArn: ListenerArn,
211639+ DefaultActions: [
211640+ {
211641+ Type: "forward",
211642+ TargetGroupArn: targetGroupArn ||
211643+ mapPortToTargetGroup[Port] ||
211644+ mapPortToTargetGroup[inputs.ports[0]],
211645+ },
211646+ ],
211647+ }));
211648+ }
211649+ }));
211645211650 console.log("Updated ALB listener's default rule");
211646211651 });
211647211652}
@@ -211683,6 +211688,14 @@ function main(inputs) {
211683211688 if (!targetEnv) {
211684211689 throw new Error("No target environment to promote");
211685211690 }
211691+ yield ebClient.send(new dist_cjs.DescribeEnvironmentsCommand({
211692+ EnvironmentIds: [targetEnv.EnvironmentId],
211693+ }))
211694+ .then(({ Environments }) => {
211695+ if (Environments[0].Health !== "Green") {
211696+ throw new Error(`Environment ${targetEnv.EnvironmentName} is not healthy. Aborting promotion.`);
211697+ }
211698+ });
211686211699 switch (inputs.strategy) {
211687211700 case DeploymentStrategy.SharedALB:
211688211701 yield updateListener(inputs, targetEnv);
0 commit comments