mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-09-02 05:55:10 +09:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05b148adc3 | |||
| 4e8c2213ad | |||
| 6b3c017dce | |||
| 45451d5084 | |||
| a27dcef2f6 | |||
| 8a29164c8b | |||
| 8d9fac2d2c | |||
| 860d476018 | |||
| 98c131dea9 | |||
| 4d108addaf | |||
| 133757e9b8 | |||
| 603116e993 | |||
| 4c5e1c60cc | |||
| 9b9980021a | |||
| f3ce02b094 | |||
| b76c725e12 | |||
| 0dbbed9302 | |||
| ebbea79d94 | |||
| 7c62b07b9f | |||
| 3fbeeb47e5 | |||
| 63e6f31c9a | |||
| bd9e4620f6 | |||
| 57753efe28 | |||
| 306df94bc9 | |||
| f6ce4d6612 | |||
| 96a6b113cd | |||
| f93938f25d | |||
| ba85598351 | |||
| b978ecdce1 | |||
| f60aed899f | |||
| abe2958c93 |
+11
-6
@@ -1,3 +1,10 @@
|
|||||||
|
queue_rules:
|
||||||
|
- name: default
|
||||||
|
conditions:
|
||||||
|
# Conditions to get out of the queue (= merged)
|
||||||
|
- status-success=Run Unit Tests
|
||||||
|
- status-success=Semantic Pull Request
|
||||||
|
|
||||||
pull_request_rules:
|
pull_request_rules:
|
||||||
- name: Automatically merge on CI success and review approval
|
- name: Automatically merge on CI success and review approval
|
||||||
conditions:
|
conditions:
|
||||||
@@ -13,10 +20,9 @@ pull_request_rules:
|
|||||||
- -closed
|
- -closed
|
||||||
- author!=dependabot[bot]
|
- author!=dependabot[bot]
|
||||||
actions:
|
actions:
|
||||||
merge:
|
queue:
|
||||||
method: squash
|
method: squash
|
||||||
strict: smart
|
name: default
|
||||||
strict_method: merge
|
|
||||||
|
|
||||||
- name: Automatically approve and merge Dependabot PRs
|
- name: Automatically approve and merge Dependabot PRs
|
||||||
conditions:
|
conditions:
|
||||||
@@ -31,7 +37,6 @@ pull_request_rules:
|
|||||||
actions:
|
actions:
|
||||||
review:
|
review:
|
||||||
type: APPROVE
|
type: APPROVE
|
||||||
merge:
|
queue:
|
||||||
method: squash
|
method: squash
|
||||||
strict: smart+fasttrack
|
name: default
|
||||||
strict_method: merge
|
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [1.6.1](https://github.com/aws-actions/configure-aws-credentials/compare/v1.6.0...v1.6.1) (2022-01-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* OIDC Parallel Requests error ([133757e](https://github.com/aws-actions/configure-aws-credentials/commit/133757e9b829f4ef44c8e99e3f272879b45fc9c5))
|
||||||
|
* Strict Mode Deprecation ([4c5e1c6](https://github.com/aws-actions/configure-aws-credentials/commit/4c5e1c60ccfc95d0e48bf1bc95fc707a94aa2c60))
|
||||||
|
|
||||||
## [1.6.0](https://github.com/aws-actions/configure-aws-credentials/compare/v1.5.11...v1.6.0) (2021-11-23)
|
## [1.6.0](https://github.com/aws-actions/configure-aws-credentials/compare/v1.5.11...v1.6.0) (2021-11-23)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+518
-119
File diff suppressed because one or more lines are too long
@@ -236,6 +236,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() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
// Get inputs
|
// Get inputs
|
||||||
@@ -303,7 +326,8 @@ async function run() {
|
|||||||
|
|
||||||
// Get role credentials if configured to do so
|
// Get role credentials if configured to do so
|
||||||
if (roleToAssume) {
|
if (roleToAssume) {
|
||||||
const roleCredentials = await assumeRole({
|
const roleCredentials = await retryAndBackoff(
|
||||||
|
async () => { return await assumeRole({
|
||||||
sourceAccountId,
|
sourceAccountId,
|
||||||
region,
|
region,
|
||||||
roleToAssume,
|
roleToAssume,
|
||||||
@@ -313,7 +337,7 @@ async function run() {
|
|||||||
roleSkipSessionTagging,
|
roleSkipSessionTagging,
|
||||||
webIdentityTokenFile,
|
webIdentityTokenFile,
|
||||||
webIdentityToken
|
webIdentityToken
|
||||||
});
|
}) }, true);
|
||||||
exportCredentials(roleCredentials);
|
exportCredentials(roleCredentials);
|
||||||
// We need to validate the credentials in 2 of our use-cases
|
// We need to validate the credentials in 2 of our use-cases
|
||||||
// First: self-hosted runners. If the GITHUB_ACTIONS environment variable
|
// First: self-hosted runners. If the GITHUB_ACTIONS environment variable
|
||||||
@@ -337,7 +361,14 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = run;
|
exports.withSleep = function (s) {
|
||||||
|
sleep = s;
|
||||||
|
};
|
||||||
|
exports.reset = function () {
|
||||||
|
sleep = defaultSleep;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.run = run
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
|||||||
+23
-1
@@ -1,7 +1,7 @@
|
|||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const aws = require('aws-sdk');
|
const aws = require('aws-sdk');
|
||||||
const run = require('./index.js');
|
const { run, withSleep, reset } = require('./index.js');
|
||||||
|
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
|
|
||||||
@@ -156,10 +156,15 @@ describe('Configure AWS Credentials', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
withSleep(() => {
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
process.env = OLD_ENV;
|
process.env = OLD_ENV;
|
||||||
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exports env vars', async () => {
|
test('exports env vars', async () => {
|
||||||
@@ -612,6 +617,23 @@ describe('Configure AWS Credentials', () => {
|
|||||||
expect(core.setSecret).toHaveBeenNthCalledWith(3, FAKE_STS_SESSION_TOKEN);
|
expect(core.setSecret).toHaveBeenNthCalledWith(3, FAKE_STS_SESSION_TOKEN);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('role assumption fails after maximun trials using OIDC Provider', async () => {
|
||||||
|
process.env.GITHUB_ACTIONS = 'true';
|
||||||
|
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = 'test-token';
|
||||||
|
|
||||||
|
core.getInput = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(mockGetInput({'role-to-assume': ROLE_ARN, 'aws-region': FAKE_REGION}));
|
||||||
|
|
||||||
|
mockStsAssumeRoleWithWebIdentity.mockReset();
|
||||||
|
mockStsAssumeRoleWithWebIdentity.mockImplementation(() => {
|
||||||
|
throw new Error();
|
||||||
|
});
|
||||||
|
|
||||||
|
await assert.rejects(() => run());
|
||||||
|
expect(mockStsAssumeRoleWithWebIdentity).toHaveBeenCalledTimes(12)
|
||||||
|
});
|
||||||
|
|
||||||
test('role external ID provided', async () => {
|
test('role external ID provided', async () => {
|
||||||
core.getInput = jest
|
core.getInput = jest
|
||||||
.fn()
|
.fn()
|
||||||
|
|||||||
Generated
+594
-710
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aws-actions-configure-aws-credentials",
|
"name": "aws-actions-configure-aws-credentials",
|
||||||
"version": "1.6.0",
|
"version": "1.6.1",
|
||||||
"description": "Configure AWS Credentials",
|
"description": "Configure AWS Credentials",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -26,12 +26,12 @@
|
|||||||
"homepage": "https://github.com/aws-actions/configure-aws-credentials#readme",
|
"homepage": "https://github.com/aws-actions/configure-aws-credentials#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^1.6.0",
|
||||||
"aws-sdk": "^2.1034.0",
|
"aws-sdk": "^2.1058.0",
|
||||||
"axios": "^0.24.0"
|
"axios": "^0.24.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^8.3.0",
|
"eslint": "^8.7.0",
|
||||||
"jest": "^27.3.1"
|
"jest": "^27.4.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user