mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-09-02 05:55:10 +09:00
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67fbcbb121 | |||
| 58bb841154 | |||
| 34779ed730 | |||
| bf7f81fcf7 | |||
| 79fafe359f | |||
| d1edd20a7e | |||
| 8a84b07f20 | |||
| 2e344a8a34 | |||
| 9f69d0f0bc | |||
| 1ca0e74a85 | |||
| 1684cc585e | |||
| 4ee5565853 | |||
| 4ff5ea70e6 | |||
| 6abb918e09 | |||
| 082f9f0637 | |||
| 2f8dfd0ed4 | |||
| f350a92ff6 | |||
| 88da7d4f1c | |||
| 18cfdaf552 | |||
| 84665e59c8 | |||
| 8788ec5aa1 | |||
| 22e077f99c | |||
| dfe025559e | |||
| 8050a91cfa | |||
| e9dce0860a | |||
| 1936d118bd | |||
| 5d27778945 | |||
| f06248b64a | |||
| ead0512447 | |||
| d63be9338f | |||
| 3ffb855336 | |||
| 25579cba53 | |||
| a64e523261 | |||
| ebad18e1cb | |||
| f324ccbd8b | |||
| f500e4423a | |||
| 717cbc82f1 | |||
| 8b86e3223d | |||
| 72ccd62416 | |||
| 852be5b0ee | |||
| 488370bebd | |||
| a8081b3d23 | |||
| fd1891d12d | |||
| 2d5d4077ee | |||
| f24ace22d4 | |||
| 05b148adc3 | |||
| 4e8c2213ad | |||
| 6b3c017dce | |||
| 45451d5084 | |||
| a27dcef2f6 | |||
| 8a29164c8b | |||
| 8d9fac2d2c | |||
| c3e3b80272 | |||
| b878f4b65b | |||
| 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,21 @@
|
|||||||
|
|
||||||
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.7.0](https://github.com/aws-actions/configure-aws-credentials/compare/v1.6.1...v1.7.0) (2022-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Allow audience to be explicitly specified ([2f8dfd0](https://github.com/aws-actions/configure-aws-credentials/commit/2f8dfd0ed43d880f85b57f0c8727b497af2037de))
|
||||||
|
|
||||||
|
### [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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ The default session duration is 1 hour when using the OIDC provider to directly
|
|||||||
The default session duration is 6 hours when using an IAM User to assume an IAM Role (by providing an `aws-access-key-id`, `aws-secret-access-key`, and a `role-to-assume`) .
|
The default session duration is 6 hours when using an IAM User to assume an IAM Role (by providing an `aws-access-key-id`, `aws-secret-access-key`, and a `role-to-assume`) .
|
||||||
If you would like to adjust this you can pass a duration to `role-duration-seconds`, but the duration cannot exceed the maximum that was defined when the IAM Role was created.
|
If you would like to adjust this you can pass a duration to `role-duration-seconds`, but the duration cannot exceed the maximum that was defined when the IAM Role was created.
|
||||||
The default session name is GitHubActions, and you can modify it by specifying the desired name in `role-session-name`.
|
The default session name is GitHubActions, and you can modify it by specifying the desired name in `role-session-name`.
|
||||||
|
The default audience is `sts.amazonaws.com` which you can replace by specifying the desired audience name in `audience`.
|
||||||
|
|
||||||
The following table describes which identity is used based on which values are supplied to the Action:
|
The following table describes which identity is used based on which values are supplied to the Action:
|
||||||
|
|
||||||
@@ -118,6 +119,19 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
|
|||||||
```
|
```
|
||||||
In this example, the secret `AWS_ROLE_TO_ASSUME` contains a string like `arn:aws:iam::123456789100:role/my-github-actions-role`. To assume a role in the same account as the static credentials, you can simply specify the role name, like `role-to-assume: my-github-actions-role`.
|
In this example, the secret `AWS_ROLE_TO_ASSUME` contains a string like `arn:aws:iam::123456789100:role/my-github-actions-role`. To assume a role in the same account as the static credentials, you can simply specify the role name, like `role-to-assume: my-github-actions-role`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Configure AWS Credentials for Beta Customers
|
||||||
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
audience: beta-customers
|
||||||
|
aws-region: us-east-3
|
||||||
|
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||||
|
role-session-name: MySessionName
|
||||||
|
```
|
||||||
|
In this example, the audience has been changed from the default to use a different audience name `beta-customers`. This can help ensure that the role can only affect those AWS accounts whose GitHub OIDC providers have explicitly opted in to the `beta-customers` label.
|
||||||
|
|
||||||
|
Changing the default audience may be necessary when using non-default [AWS partitions](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
|
||||||
|
|
||||||
### Sample IAM Role CloudFormation Template
|
### Sample IAM Role CloudFormation Template
|
||||||
```yaml
|
```yaml
|
||||||
Parameters:
|
Parameters:
|
||||||
@@ -160,7 +174,7 @@ Resources:
|
|||||||
ClientIdList:
|
ClientIdList:
|
||||||
- sts.amazonaws.com
|
- sts.amazonaws.com
|
||||||
ThumbprintList:
|
ThumbprintList:
|
||||||
- a031c46782e6e6c662c2c87c76da9aa62ccabd8e
|
- 6938fd4d98bab03faadb97b34396831e3780aea1
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
Role:
|
Role:
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ branding:
|
|||||||
icon: 'cloud'
|
icon: 'cloud'
|
||||||
color: 'orange'
|
color: 'orange'
|
||||||
inputs:
|
inputs:
|
||||||
|
audience:
|
||||||
|
default: 'sts.amazonaws.com'
|
||||||
|
description: 'The audience to use for the OIDC provider'
|
||||||
|
required: false
|
||||||
aws-access-key-id:
|
aws-access-key-id:
|
||||||
description: >-
|
description: >-
|
||||||
AWS Access Key ID. This input is required if running in the GitHub hosted environment.
|
AWS Access Key ID. This input is required if running in the GitHub hosted environment.
|
||||||
|
|||||||
Vendored
+1079
-229
File diff suppressed because one or more lines are too long
@@ -236,10 +236,34 @@ 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
|
||||||
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
|
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
|
||||||
|
const audience = core.getInput('audience', { required: false });
|
||||||
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
|
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
|
||||||
const region = core.getInput('aws-region', { required: true });
|
const region = core.getInput('aws-region', { required: true });
|
||||||
const sessionToken = core.getInput('aws-session-token', { required: false });
|
const sessionToken = core.getInput('aws-session-token', { required: false });
|
||||||
@@ -287,7 +311,7 @@ async function run() {
|
|||||||
let sourceAccountId;
|
let sourceAccountId;
|
||||||
let webIdentityToken;
|
let webIdentityToken;
|
||||||
if(useGitHubOIDCProvider()) {
|
if(useGitHubOIDCProvider()) {
|
||||||
webIdentityToken = await core.getIDToken('sts.amazonaws.com');
|
webIdentityToken = await core.getIDToken(audience);
|
||||||
roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES;
|
roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES;
|
||||||
// We don't validate the credentials here because we don't have them yet when using OIDC.
|
// We don't validate the credentials here because we don't have them yet when using OIDC.
|
||||||
} else {
|
} else {
|
||||||
@@ -303,7 +327,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 +338,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 +362,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
+704
-763
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aws-actions-configure-aws-credentials",
|
"name": "aws-actions-configure-aws-credentials",
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"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.1112.0",
|
||||||
"axios": "^0.24.0"
|
"axios": "^0.26.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^8.3.0",
|
"eslint": "^8.13.0",
|
||||||
"jest": "^27.3.1"
|
"jest": "^27.5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user