mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-09-03 06:05:04 +09:00
chore: Update dist
This commit is contained in:
Vendored
+40
-11
@@ -166,6 +166,8 @@ module.exports = AWS.MediaLive;
|
|||||||
const core = __webpack_require__(6470);
|
const core = __webpack_require__(6470);
|
||||||
const aws = __webpack_require__(9350);
|
const aws = __webpack_require__(9350);
|
||||||
const assert = __webpack_require__(2357);
|
const assert = __webpack_require__(2357);
|
||||||
|
const fs = __webpack_require__(5747);
|
||||||
|
const path = __webpack_require__(5622);
|
||||||
|
|
||||||
// The max time that a GitHub action is allowed to run is 6 hours.
|
// The max time that a GitHub action is allowed to run is 6 hours.
|
||||||
// That seems like a reasonable default to use if no role duration is defined.
|
// That seems like a reasonable default to use if no role duration is defined.
|
||||||
@@ -187,7 +189,8 @@ async function assumeRole(params) {
|
|||||||
roleDurationSeconds,
|
roleDurationSeconds,
|
||||||
roleSessionName,
|
roleSessionName,
|
||||||
region,
|
region,
|
||||||
roleSkipSessionTagging
|
roleSkipSessionTagging,
|
||||||
|
webIdentityTokenFile
|
||||||
} = params;
|
} = params;
|
||||||
assert(
|
assert(
|
||||||
[sourceAccountId, roleToAssume, roleDurationSeconds, roleSessionName, region].every(isDefined),
|
[sourceAccountId, roleToAssume, roleDurationSeconds, roleSessionName, region].every(isDefined),
|
||||||
@@ -207,6 +210,7 @@ async function assumeRole(params) {
|
|||||||
// Supports only 'aws' partition. Customers in other partitions ('aws-cn') will need to provide full ARN
|
// Supports only 'aws' partition. Customers in other partitions ('aws-cn') will need to provide full ARN
|
||||||
roleArn = `arn:aws:iam::${sourceAccountId}:role/${roleArn}`;
|
roleArn = `arn:aws:iam::${sourceAccountId}:role/${roleArn}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagArray = [
|
const tagArray = [
|
||||||
{Key: 'GitHub', Value: 'Actions'},
|
{Key: 'GitHub', Value: 'Actions'},
|
||||||
{Key: 'Repository', Value: GITHUB_REPOSITORY},
|
{Key: 'Repository', Value: GITHUB_REPOSITORY},
|
||||||
@@ -239,15 +243,38 @@ async function assumeRole(params) {
|
|||||||
assumeRoleRequest.ExternalId = roleExternalId;
|
assumeRoleRequest.ExternalId = roleExternalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sts.assumeRole(assumeRoleRequest)
|
let assumeFunction = sts.assumeRole.bind(sts);
|
||||||
.promise()
|
|
||||||
.then(function (data) {
|
if(isDefined(webIdentityTokenFile)) {
|
||||||
return {
|
core.debug("webIdentityTokenFile provided. Will call sts:AssumeRoleWithWebIdentity and take session tags from token contents.")
|
||||||
accessKeyId: data.Credentials.AccessKeyId,
|
delete assumeRoleRequest.Tags;
|
||||||
secretAccessKey: data.Credentials.SecretAccessKey,
|
|
||||||
sessionToken: data.Credentials.SessionToken,
|
const webIdentityTokenFilePath = path.isAbsolute(webIdentityTokenFile) ?
|
||||||
};
|
webIdentityTokenFile :
|
||||||
});
|
path.join(process.env.GITHUB_WORKSPACE, webIdentityTokenFile);
|
||||||
|
|
||||||
|
if (!fs.existsSync(webIdentityTokenFilePath)) {
|
||||||
|
throw new Error(`Web identity token file does not exist: ${webIdentityTokenFilePath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
assumeRoleRequest.WebIdentityToken = await fs.promises.readFile(webIdentityTokenFilePath, 'utf8');
|
||||||
|
assumeFunction = sts.assumeRoleWithWebIdentity.bind(sts);
|
||||||
|
} catch(error) {
|
||||||
|
throw new Error(`Web identity token file could not be read: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return assumeFunction(assumeRoleRequest)
|
||||||
|
.promise()
|
||||||
|
.then(function (data) {
|
||||||
|
return {
|
||||||
|
accessKeyId: data.Credentials.AccessKeyId,
|
||||||
|
secretAccessKey: data.Credentials.SecretAccessKey,
|
||||||
|
sessionToken: data.Credentials.SessionToken,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeGithubActor(actor) {
|
function sanitizeGithubActor(actor) {
|
||||||
@@ -376,6 +403,7 @@ async function run() {
|
|||||||
const roleSessionName = core.getInput('role-session-name', { required: false }) || ROLE_SESSION_NAME;
|
const roleSessionName = core.getInput('role-session-name', { required: false }) || ROLE_SESSION_NAME;
|
||||||
const roleSkipSessionTaggingInput = core.getInput('role-skip-session-tagging', { required: false })|| 'false';
|
const roleSkipSessionTaggingInput = core.getInput('role-skip-session-tagging', { required: false })|| 'false';
|
||||||
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
||||||
|
const webIdentityTokenFile = core.getInput('web-identity-token-file', { required: false })
|
||||||
|
|
||||||
if (!region.match(REGION_REGEX)) {
|
if (!region.match(REGION_REGEX)) {
|
||||||
throw new Error(`Region is not valid: ${region}`);
|
throw new Error(`Region is not valid: ${region}`);
|
||||||
@@ -414,7 +442,8 @@ async function run() {
|
|||||||
roleExternalId,
|
roleExternalId,
|
||||||
roleDurationSeconds,
|
roleDurationSeconds,
|
||||||
roleSessionName,
|
roleSessionName,
|
||||||
roleSkipSessionTagging
|
roleSkipSessionTagging,
|
||||||
|
webIdentityTokenFile
|
||||||
});
|
});
|
||||||
exportCredentials(roleCredentials);
|
exportCredentials(roleCredentials);
|
||||||
await validateCredentials(roleCredentials.accessKeyId);
|
await validateCredentials(roleCredentials.accessKeyId);
|
||||||
|
|||||||
Reference in New Issue
Block a user