Skip to content

Commit

Permalink
improve environment filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
tmshkr committed Jan 3, 2024
1 parent 2afc07e commit 84c6f1b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/updateListenerRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ interface RulesByArn {
}

export async function removeTargetGroups(inputs: ActionInputs) {
const { prodEnv, stagingEnv } = await getEnvironments(inputs);
const environments = [prodEnv, stagingEnv].filter((env) => !!env);
const { stagingEnv } = await getEnvironments(inputs);
const environments = [stagingEnv].filter((env) => !!env);
const resources = await getEnvironmentResources(environments);
const rules = await getRules(resources);

Expand Down Expand Up @@ -72,9 +72,18 @@ export async function removeTargetGroups(inputs: ActionInputs) {

export async function updateTargetGroups(inputs: ActionInputs) {
const { prodEnv, stagingEnv } = await getEnvironments(inputs);
const environments = [prodEnv, stagingEnv].filter(
(env) => env?.Status === "Ready" && env?.Health === "Green"
);
const environments = [prodEnv, stagingEnv].filter((env) => {
if (!env) return false;
if (env.Status !== "Ready") {
console.log(`${env.EnvironmentName} not ready, skipping...`);
return false;
}
if (env.Health !== "Green") {
console.warn(`Warning: ${env.EnvironmentName} Health is ${env.Health}`);
}
return true;
});

const resources = await getEnvironmentResources(environments);
const rules = await getRules(resources);
const targetGroupARNs = await findTargetGroupArns(
Expand Down

0 comments on commit 84c6f1b

Please sign in to comment.