mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-03-12 18:07:10 -04:00
chore: Update dist
This commit is contained in:
57
dist/index.js
vendored
57
dist/index.js
vendored
@@ -168,7 +168,7 @@ module.exports = AWS.MediaLive;
|
||||
/***/ }),
|
||||
|
||||
/***/ 104:
|
||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||
|
||||
const core = __webpack_require__(6470);
|
||||
const aws = __webpack_require__(9350);
|
||||
@@ -408,6 +408,29 @@ function getStsClient(region) {
|
||||
});
|
||||
}
|
||||
|
||||
let defaultSleep = function (ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
};
|
||||
let sleep = defaultSleep;
|
||||
|
||||
// retryAndBackoff retries with exponential backoff the promise if the error isRetryable upto maxRetries time.
|
||||
const retryAndBackoff = async (fn, isRetryable, retries = 0, maxRetries = 12, base = 50) => {
|
||||
try {
|
||||
return await fn();
|
||||
} catch (err) {
|
||||
if (!isRetryable) {
|
||||
throw err;
|
||||
}
|
||||
// It's retryable, so sleep and retry.
|
||||
await sleep(Math.random() * (Math.pow(2, retries) * base) );
|
||||
retries += 1;
|
||||
if (retries === maxRetries) {
|
||||
throw err;
|
||||
}
|
||||
return await retryAndBackoff(fn, isRetryable, retries, maxRetries, base);
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
// Get inputs
|
||||
@@ -475,17 +498,18 @@ async function run() {
|
||||
|
||||
// Get role credentials if configured to do so
|
||||
if (roleToAssume) {
|
||||
const roleCredentials = await assumeRole({
|
||||
sourceAccountId,
|
||||
region,
|
||||
roleToAssume,
|
||||
roleExternalId,
|
||||
roleDurationSeconds,
|
||||
roleSessionName,
|
||||
roleSkipSessionTagging,
|
||||
webIdentityTokenFile,
|
||||
webIdentityToken
|
||||
});
|
||||
const roleCredentials = await retryAndBackoff(
|
||||
async () => { return await assumeRole({
|
||||
sourceAccountId,
|
||||
region,
|
||||
roleToAssume,
|
||||
roleExternalId,
|
||||
roleDurationSeconds,
|
||||
roleSessionName,
|
||||
roleSkipSessionTagging,
|
||||
webIdentityTokenFile,
|
||||
webIdentityToken
|
||||
}) }, true);
|
||||
exportCredentials(roleCredentials);
|
||||
// We need to validate the credentials in 2 of our use-cases
|
||||
// First: self-hosted runners. If the GITHUB_ACTIONS environment variable
|
||||
@@ -509,7 +533,14 @@ async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = run;
|
||||
exports.withSleep = function (s) {
|
||||
sleep = s;
|
||||
};
|
||||
exports.reset = function () {
|
||||
sleep = defaultSleep;
|
||||
};
|
||||
|
||||
exports.run = run
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (require.main === require.cache[eval('__filename')]) {
|
||||
|
||||
Reference in New Issue
Block a user