From 6a2933a4c7c7194af464bd88200623e685e9a62d Mon Sep 17 00:00:00 2001 From: Mike <36415632+Mike-Heneghan@users.noreply.github.com> Date: Fri, 26 Jan 2024 23:28:54 +0000 Subject: [PATCH] fix: logical error with assigning gov pay secret (#2709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dafydd Llŷr Pearson --- .../application/utils/generateTeamSecrets.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/infrastructure/application/utils/generateTeamSecrets.ts b/infrastructure/application/utils/generateTeamSecrets.ts index 7bb906cc51..702f184e14 100644 --- a/infrastructure/application/utils/generateTeamSecrets.ts +++ b/infrastructure/application/utils/generateTeamSecrets.ts @@ -25,15 +25,27 @@ export const generateTeamSecrets = ( ): awsx.ecs.KeyValuePair[] => { const secrets: awsx.ecs.KeyValuePair[] = []; teams.forEach((team) => { - if (team?.govPayStagingOnly && env !== "production") { - secrets.push({ - name: `GOV_UK_PAY_TOKEN_${name(team.name)}`, - value: - env === "sandbox" - ? "sandbox" - : config.require(`gov-uk-pay-token-${value(team.name)}`), - }); - } + switch(env) { + case "sandbox": + secrets.push({ + name: `GOV_UK_PAY_TOKEN_${name(team.name)}`, + value: "sandbox" + }); + break; + case "staging": + secrets.push({ + name: `GOV_UK_PAY_TOKEN_${name(team.name)}`, + value: config.require(`gov-uk-pay-token-${value(team.name)}`), + }); + break; + case "production": + if (!team?.govPayStagingOnly) { + secrets.push({ + name: `GOV_UK_PAY_TOKEN_${name(team.name)}`, + value: config.require(`gov-uk-pay-token-${value(team.name)}`), + }); + } + }; team.uniformInstances?.forEach((instance) => { secrets.push({ name: `UNIFORM_CLIENT_${name(instance)}`,