diff --git a/dist/index.js b/dist/index.js index 5e77544..bbf26a0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -71149,7 +71149,7 @@ function verifyKeys(creds) { } return true; } -async function retryAndBackoff(fn, isRetryable, maxRetries = 12, retries = 0, base = 50, label) { +async function retryAndBackoff(fn, isRetryable, maxRetries = 12, retries = 0, base = 50) { try { return await fn(); } catch (err) { @@ -71159,16 +71159,15 @@ async function retryAndBackoff(fn, isRetryable, maxRetries = 12, retries = 0, ba } const delay = Math.random() * (2 ** retries * base); const nextRetry = retries + 1; - const opName = label ? ` ${label}` : ""; - info( - `Retry${opName}: attempt ${nextRetry} of ${maxRetries} failed: ${errorMessage(err)}. Retrying after ${Math.floor(delay)}ms.` + debug( + `retryAndBackoff: attempt ${nextRetry} of ${maxRetries} failed: ${errorMessage(err)}. Retrying after ${Math.floor(delay)}ms.` ); await sleep(delay); if (nextRetry >= maxRetries) { - info(`Retry${opName}: reached max retries (${maxRetries}); giving up.`); + debug("retryAndBackoff: reached max retries; giving up."); throw err; } - return await retryAndBackoff(fn, isRetryable, maxRetries, nextRetry, base, label); + return await retryAndBackoff(fn, isRetryable, maxRetries, nextRetry, base); } } function errorMessage(error3) { @@ -72862,7 +72861,6 @@ async function run() { } else if (maxRetries < 1) { maxRetries = 1; } - const withRetry = (fn, label) => retryAndBackoff(fn, !disableRetry, maxRetries, 0, 50, label); const useGitHubOIDCProvider = () => { if (forceSkipOidc) return false; if (!!roleToAssume && !webIdentityTokenFile && !AccessKeyId && !process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN && !roleChaining) { @@ -72900,9 +72898,13 @@ async function run() { } if (useGitHubOIDCProvider()) { try { - webIdentityToken = await withRetry(async () => { - return getIDToken(audience); - }, "getIDToken"); + webIdentityToken = await retryAndBackoff( + async () => { + return getIDToken(audience); + }, + !disableRetry, + maxRetries + ); } catch (error3) { throw new Error(`getIDToken call failed: ${errorMessage(error3)}`); } @@ -72915,18 +72917,12 @@ async function run() { writeProfileFiles(awsProfile, { AccessKeyId, SecretAccessKey, SessionToken }, region, overwriteAwsProfile); } } else if (!webIdentityTokenFile && !roleChaining) { - await withRetry( - () => credentialsClient.validateCredentials(void 0, roleChaining, expectedAccountIds), - "validateCredentials" - ); - sourceAccountId = await withRetry(() => exportAccountId(credentialsClient, maskAccountId), "exportAccountId"); + await credentialsClient.validateCredentials(void 0, roleChaining, expectedAccountIds); + sourceAccountId = await exportAccountId(credentialsClient, maskAccountId); } if (AccessKeyId || roleChaining) { - await withRetry( - () => credentialsClient.validateCredentials(AccessKeyId, roleChaining, expectedAccountIds), - "validateCredentials" - ); - sourceAccountId = await withRetry(() => exportAccountId(credentialsClient, maskAccountId), "exportAccountId"); + await credentialsClient.validateCredentials(AccessKeyId, roleChaining, expectedAccountIds); + sourceAccountId = await exportAccountId(credentialsClient, maskAccountId); } if (customTags && (useGitHubOIDCProvider() || webIdentityTokenFile)) { warning( @@ -72936,38 +72932,39 @@ async function run() { if (roleToAssume) { let roleCredentials; do { - roleCredentials = await withRetry(async () => { - return assumeRole({ - credentialsClient, - sourceAccountId, - roleToAssume, - roleExternalId, - roleDuration, - roleSessionName, - roleSkipSessionTagging, - transitiveTagKeys, - webIdentityTokenFile, - webIdentityToken, - inlineSessionPolicy, - managedSessionPolicies, - customTags - }); - }, "AssumeRole"); + roleCredentials = await retryAndBackoff( + async () => { + return assumeRole({ + credentialsClient, + sourceAccountId, + roleToAssume, + roleExternalId, + roleDuration, + roleSessionName, + roleSkipSessionTagging, + transitiveTagKeys, + webIdentityTokenFile, + webIdentityToken, + inlineSessionPolicy, + managedSessionPolicies, + customTags + }); + }, + !disableRetry, + maxRetries + ); } while (specialCharacterWorkaround && !verifyKeys(roleCredentials.Credentials)); info(`Authenticated as assumedRoleId ${roleCredentials.AssumedRoleUser?.AssumedRoleId}`); exportCredentials(roleCredentials.Credentials, outputCredentials, outputEnvCredentials); if ((!process.env.GITHUB_ACTIONS || AccessKeyId) && !awsProfile) { - await withRetry( - () => credentialsClient.validateCredentials( - roleCredentials.Credentials?.AccessKeyId, - roleChaining, - expectedAccountIds - ), - "validateCredentials" + await credentialsClient.validateCredentials( + roleCredentials.Credentials?.AccessKeyId, + roleChaining, + expectedAccountIds ); } if (outputEnvCredentials) { - await withRetry(() => exportAccountId(credentialsClient, maskAccountId), "exportAccountId"); + await exportAccountId(credentialsClient, maskAccountId); } if (awsProfile) { if (!roleCredentials.Credentials) { @@ -72975,13 +72972,10 @@ async function run() { } if (AccessKeyId || !process.env.GITHUB_ACTIONS) { writeProfileFiles(awsProfile, roleCredentials.Credentials, region, true); - await withRetry( - () => credentialsClient.validateCredentials( - roleCredentials.Credentials?.AccessKeyId, - roleChaining, - expectedAccountIds - ), - "validateCredentials" + await credentialsClient.validateCredentials( + roleCredentials.Credentials.AccessKeyId, + roleChaining, + expectedAccountIds ); } else { writeProfileFiles(awsProfile, roleCredentials.Credentials, region, overwriteAwsProfile);