mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-06-09 12:17:08 +00:00
chore: Update dist
This commit is contained in:
parent
8053174404
commit
1f1eb0f055
1 changed files with 40 additions and 11 deletions
51
dist/index.js
vendored
51
dist/index.js
vendored
|
|
@ -166,6 +166,8 @@ module.exports = AWS.MediaLive;
|
|||
const core = __webpack_require__(6470);
|
||||
const aws = __webpack_require__(9350);
|
||||
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.
|
||||
// That seems like a reasonable default to use if no role duration is defined.
|
||||
|
|
@ -187,7 +189,8 @@ async function assumeRole(params) {
|
|||
roleDurationSeconds,
|
||||
roleSessionName,
|
||||
region,
|
||||
roleSkipSessionTagging
|
||||
roleSkipSessionTagging,
|
||||
webIdentityTokenFile
|
||||
} = params;
|
||||
assert(
|
||||
[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
|
||||
roleArn = `arn:aws:iam::${sourceAccountId}:role/${roleArn}`;
|
||||
}
|
||||
|
||||
const tagArray = [
|
||||
{Key: 'GitHub', Value: 'Actions'},
|
||||
{Key: 'Repository', Value: GITHUB_REPOSITORY},
|
||||
|
|
@ -239,15 +243,38 @@ async function assumeRole(params) {
|
|||
assumeRoleRequest.ExternalId = roleExternalId;
|
||||
}
|
||||
|
||||
return sts.assumeRole(assumeRoleRequest)
|
||||
.promise()
|
||||
.then(function (data) {
|
||||
return {
|
||||
accessKeyId: data.Credentials.AccessKeyId,
|
||||
secretAccessKey: data.Credentials.SecretAccessKey,
|
||||
sessionToken: data.Credentials.SessionToken,
|
||||
};
|
||||
});
|
||||
let assumeFunction = sts.assumeRole.bind(sts);
|
||||
|
||||
if(isDefined(webIdentityTokenFile)) {
|
||||
core.debug("webIdentityTokenFile provided. Will call sts:AssumeRoleWithWebIdentity and take session tags from token contents.")
|
||||
delete assumeRoleRequest.Tags;
|
||||
|
||||
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) {
|
||||
|
|
@ -376,6 +403,7 @@ async function run() {
|
|||
const roleSessionName = core.getInput('role-session-name', { required: false }) || ROLE_SESSION_NAME;
|
||||
const roleSkipSessionTaggingInput = core.getInput('role-skip-session-tagging', { required: false })|| 'false';
|
||||
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
||||
const webIdentityTokenFile = core.getInput('web-identity-token-file', { required: false })
|
||||
|
||||
if (!region.match(REGION_REGEX)) {
|
||||
throw new Error(`Region is not valid: ${region}`);
|
||||
|
|
@ -414,7 +442,8 @@ async function run() {
|
|||
roleExternalId,
|
||||
roleDurationSeconds,
|
||||
roleSessionName,
|
||||
roleSkipSessionTagging
|
||||
roleSkipSessionTagging,
|
||||
webIdentityTokenFile
|
||||
});
|
||||
exportCredentials(roleCredentials);
|
||||
await validateCredentials(roleCredentials.accessKeyId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue