From a8be9d64e1d34d46f754512a00a17c386538b034 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Tue, 22 Aug 2023 17:03:09 +0200 Subject: [PATCH] OPSEXP-2250 Fix s3 download command in init aps (#8842) --- lib/cli/scripts/init-aps-env.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/cli/scripts/init-aps-env.ts b/lib/cli/scripts/init-aps-env.ts index 994d8eb21a..5a3099154f 100755 --- a/lib/cli/scripts/init-aps-env.ts +++ b/lib/cli/scripts/init-aps-env.ts @@ -435,17 +435,23 @@ async function authorizeUserToContentWithBasic(username: string, contentId: stri } async function downloadLicenseFile(apsLicensePath: string) { - try { - spawnSync(` aws s3 cp ${apsLicensePath} ./ `, { - cwd: path.resolve(__dirname, `./`), - shell: false - }); - logger.info(`Aps license file download from S3 bucket`); - return true; - } catch (error) { - logger.error(`Not able to download the APS license from S3 bucket` ); + const args = [ + `s3`, + `cp`, + apsLicensePath, + `./` + ]; + const result = spawnSync(`aws`, args, { + cwd: path.resolve(__dirname, `./`), + shell: false + }); + + if (result.status !== 0) { + logger.error(`Not able to download the APS license from S3 bucket.\nCommand aws ${args.join(' ')} - failed with:\n${result.output}`); return false; } + logger.info(`Aps license file download from S3 bucket`); + return true; } function sleep(delay: number) {