Compare commits

...

9 Commits

Author SHA1 Message Date
Release Automation 6835cc9216 chore(release): 1.4.3 2020-07-14 19:42:41 +00:00
GitHub Actions bb38f46f0f chore: Update dist 2020-07-10 12:02:38 +00:00
dependabot[bot] e55fab9d37 chore: Bump aws-sdk from 2.708.0 to 2.713.0 (#96)
Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.708.0 to 2.713.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js/compare/v2.708.0...v2.713.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-10 12:02:06 +00:00
GitHub Actions 740d8a44f8 chore: Update dist 2020-07-08 23:25:49 +00:00
KeifferCulbreth baf85d8be9 fix: Make tagging optional (#92)
* fix:making role session tagging optional

* test:improve test coverage

Add test to cover error thrown if access key exists and no secret key provided

* docs: Update README.md

Add details about skipping session tagging during role assumption

Co-authored-by: KeifferCulbreth <KeifferCulbreth@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-07-08 23:25:05 +00:00
dependabot[bot] b3a87c1114 chore: Bump eslint from 7.3.1 to 7.4.0 (#94)
Bumps [eslint](https://github.com/eslint/eslint) from 7.3.1 to 7.4.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.3.1...v7.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-07 05:46:11 +00:00
GitHub Actions 9ba95ecaf9 chore: Update dist 2020-06-30 19:38:24 +00:00
dependabot[bot] 2e0b693663 chore: Bump aws-sdk from 2.707.0 to 2.708.0 (#90)
Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.707.0 to 2.708.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js/compare/v2.707.0...v2.708.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-06-30 19:37:54 +00:00
Piradeep Kandasamy 2f596bbeba chore: update dependabot schedule (#89) 2020-06-30 19:35:55 +00:00
9 changed files with 170 additions and 76 deletions
+2 -1
View File
@@ -3,5 +3,6 @@ updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: "/" directory: "/"
schedule: schedule:
interval: monthly interval: weekly
day: tuesday
open-pull-requests-limit: 10 open-pull-requests-limit: 10
+7
View File
@@ -2,6 +2,13 @@
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.4.3](https://github.com/aws-actions/configure-aws-credentials/compare/v1.4.2...v1.4.3) (2020-07-14)
### Bug Fixes
* Make tagging optional ([#92](https://github.com/aws-actions/configure-aws-credentials/issues/92)) ([baf85d8](https://github.com/aws-actions/configure-aws-credentials/commit/baf85d8be969f190df9bc9153f06958c32ef3828))
### [1.4.2](https://github.com/aws-actions/configure-aws-credentials/compare/v1.4.1...v1.4.2) (2020-06-30) ### [1.4.2](https://github.com/aws-actions/configure-aws-credentials/compare/v1.4.1...v1.4.2) (2020-06-30)
+8
View File
@@ -157,6 +157,14 @@ The session will have the name "GitHubActions" and be tagged with the following
_Note: all tag values must conform to [the requirements](https://docs.aws.amazon.com/STS/latest/APIReference/API_Tag.html). Particularly, `GITHUB_WORKFLOW` will be truncated if it's too long. If `GITHUB_ACTOR` or `GITHUB_WORKFLOW` contain invalid charcters, the characters will be replaced with an '*'._ _Note: all tag values must conform to [the requirements](https://docs.aws.amazon.com/STS/latest/APIReference/API_Tag.html). Particularly, `GITHUB_WORKFLOW` will be truncated if it's too long. If `GITHUB_ACTOR` or `GITHUB_WORKFLOW` contain invalid charcters, the characters will be replaced with an '*'._
The action will use session tagging by default during role assumption. You can skip this session tagging by providing `role-skip-session-tagging` as true in the action's inputs:
```yaml
uses: aws-actions/configure-aws-credentials@v1
with:
role-skip-session-tagging: true
```
## Self-Hosted Runners ## Self-Hosted Runners
If you run your GitHub Actions in a [self-hosted runner](https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) that already has access to AWS credentials, such as an EC2 instance, then you do not need to provide IAM user access key credentials to this action. If you run your GitHub Actions in a [self-hosted runner](https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) that already has access to AWS credentials, such as an EC2 instance, then you do not need to provide IAM user access key credentials to this action.
+3
View File
@@ -43,6 +43,9 @@ inputs:
role-external-id: role-external-id:
description: 'The external ID of the role to assume' description: 'The external ID of the role to assume'
required: false required: false
role-skip-session-tagging:
description: 'Skip session tagging during role assumption'
required: false
outputs: outputs:
aws-account-id: aws-account-id:
description: 'The AWS account ID for the provided credentials' description: 'The AWS account ID for the provided credentials'
+45 -39
View File
File diff suppressed because one or more lines are too long
+17 -11
View File
@@ -22,6 +22,7 @@ async function assumeRole(params) {
roleDurationSeconds, roleDurationSeconds,
roleSessionName, roleSessionName,
region, region,
roleSkipSessionTagging
} = params; } = params;
assert( assert(
[sourceAccountId, roleToAssume, roleDurationSeconds, roleSessionName, region].every(isDefined), [sourceAccountId, roleToAssume, roleDurationSeconds, roleSessionName, region].every(isDefined),
@@ -41,20 +42,23 @@ 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 = [
{Key: 'GitHub', Value: 'Actions'},
{Key: 'Repository', Value: GITHUB_REPOSITORY},
{Key: 'Workflow', Value: sanitizeGithubWorkflowName(GITHUB_WORKFLOW)},
{Key: 'Action', Value: GITHUB_ACTION},
{Key: 'Actor', Value: sanitizeGithubActor(GITHUB_ACTOR)},
{Key: 'Branch', Value: GITHUB_REF},
{Key: 'Commit', Value: GITHUB_SHA},
];
const roleSessionTags = roleSkipSessionTagging ? undefined : tagArray;
const assumeRoleRequest = { const assumeRoleRequest = {
RoleArn: roleArn, RoleArn: roleArn,
RoleSessionName: roleSessionName, RoleSessionName: roleSessionName,
DurationSeconds: roleDurationSeconds, DurationSeconds: roleDurationSeconds,
Tags: [ Tags: roleSessionTags
{Key: 'GitHub', Value: 'Actions'},
{Key: 'Repository', Value: GITHUB_REPOSITORY},
{Key: 'Workflow', Value: sanitizeGithubWorkflowName(GITHUB_WORKFLOW)},
{Key: 'Action', Value: GITHUB_ACTION},
{Key: 'Actor', Value: sanitizeGithubActor(GITHUB_ACTOR)},
{Key: 'Branch', Value: GITHUB_REF},
{Key: 'Commit', Value: GITHUB_SHA},
]
}; };
if (roleExternalId) { if (roleExternalId) {
@@ -196,7 +200,8 @@ async function run() {
const roleExternalId = core.getInput('role-external-id', { required: false }); const roleExternalId = core.getInput('role-external-id', { required: false });
const roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || MAX_ACTION_RUNTIME; const roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || MAX_ACTION_RUNTIME;
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 roleSkipSessionTagging = core.getInput('role-skip-session-tagging', { 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}`);
} }
@@ -233,7 +238,8 @@ async function run() {
roleToAssume, roleToAssume,
roleExternalId, roleExternalId,
roleDurationSeconds, roleDurationSeconds,
roleSessionName roleSessionName,
roleSkipSessionTagging
}); });
exportCredentials(roleCredentials); exportCredentials(roleCredentials);
await validateCredentials(roleCredentials.accessKeyId); await validateCredentials(roleCredentials.accessKeyId);
+71
View File
@@ -276,6 +276,19 @@ describe('Configure AWS Credentials', () => {
expect(core.setFailed).toHaveBeenCalledWith('Region is not valid: $AWS_REGION'); expect(core.setFailed).toHaveBeenCalledWith('Region is not valid: $AWS_REGION');
}); });
test('throws error if access key id exists but missing secret access key', async () => {
process.env.SHOW_STACK_TRACE = 'false';
const inputsWIthoutSecretKey = {...ASSUME_ROLE_INPUTS}
inputsWIthoutSecretKey["aws-secret-access-key"] = undefined
core.getInput = jest
.fn()
.mockImplementation(mockGetInput(inputsWIthoutSecretKey));
await run();
expect(core.setFailed).toHaveBeenCalledWith("'aws-secret-access-key' must be provided if 'aws-access-key-id' is provided");
});
test('can opt out of masking account ID', async () => { test('can opt out of masking account ID', async () => {
const mockInputs = {...CREDS_INPUTS, 'aws-region': 'us-east-1', 'mask-aws-account-id': 'false'}; const mockInputs = {...CREDS_INPUTS, 'aws-region': 'us-east-1', 'mask-aws-account-id': 'false'};
core.getInput = jest core.getInput = jest
@@ -523,4 +536,62 @@ describe('Configure AWS Credentials', () => {
}) })
}); });
test('skip tagging provided as true', async () => {
core.getInput = jest
.fn()
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS, 'role-skip-session-tagging': true}));
await run();
expect(mockStsAssumeRole).toHaveBeenCalledWith({
RoleArn: ROLE_ARN,
RoleSessionName: 'GitHubActions',
DurationSeconds: 21600,
Tags: undefined
})
});
test('skip tagging provided as false', async () => {
core.getInput = jest
.fn()
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS, 'role-skip-session-tagging': false}));
await run();
expect(mockStsAssumeRole).toHaveBeenCalledWith({
RoleArn: ROLE_ARN,
RoleSessionName: 'GitHubActions',
DurationSeconds: 21600,
Tags: [
{Key: 'GitHub', Value: 'Actions'},
{Key: 'Repository', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REPOSITORY},
{Key: 'Workflow', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_WORKFLOW},
{Key: 'Action', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_ACTION},
{Key: 'Actor', Value: GITHUB_ACTOR_SANITIZED},
{Key: 'Branch', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REF},
{Key: 'Commit', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_SHA},
]
})
});
test('skip tagging not provided', async () => {
core.getInput = jest
.fn()
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS}));
await run();
expect(mockStsAssumeRole).toHaveBeenCalledWith({
RoleArn: ROLE_ARN,
RoleSessionName: 'GitHubActions',
DurationSeconds: 21600,
Tags: [
{Key: 'GitHub', Value: 'Actions'},
{Key: 'Repository', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REPOSITORY},
{Key: 'Workflow', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_WORKFLOW},
{Key: 'Action', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_ACTION},
{Key: 'Actor', Value: GITHUB_ACTOR_SANITIZED},
{Key: 'Branch', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REF},
{Key: 'Commit', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_SHA},
]
})
});
}); });
+14 -22
View File
@@ -1,6 +1,6 @@
{ {
"name": "aws-actions-configure-aws-credentials", "name": "aws-actions-configure-aws-credentials",
"version": "1.4.2", "version": "1.4.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -1078,9 +1078,9 @@
} }
}, },
"ansi-colors": { "ansi-colors": {
"version": "3.2.4", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
"integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==", "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true "dev": true
}, },
"ansi-escapes": { "ansi-escapes": {
@@ -1198,9 +1198,9 @@
"dev": true "dev": true
}, },
"aws-sdk": { "aws-sdk": {
"version": "2.707.0", "version": "2.713.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.707.0.tgz", "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.713.0.tgz",
"integrity": "sha512-nt55Z9wQKFodOuwElF3222Thc3kDVnaC4rwemPEHIM1cVGPQe6E5yBfc6AwtYmSo6eoMMEWd6XO5wG2am9PW0w==", "integrity": "sha512-axR1eOVn134KXJc1IT+Au2TXcK6oswY+4nvGe5GfU3pXeehhe0xNeP9Bw9yF36TRBxuvu4IJ2hRHDKma05smgA==",
"requires": { "requires": {
"buffer": "4.9.2", "buffer": "4.9.2",
"events": "1.1.1", "events": "1.1.1",
@@ -1876,12 +1876,12 @@
} }
}, },
"enquirer": { "enquirer": {
"version": "2.3.5", "version": "2.3.6",
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.5.tgz", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
"integrity": "sha512-BNT1C08P9XD0vNg3J475yIUG+mVdp9T6towYFHUv897X0KoHBjB1shyrNmhmtHWKP17iSWgo7Gqh7BBuzLZMSA==", "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
"dev": true, "dev": true,
"requires": { "requires": {
"ansi-colors": "^3.2.1" "ansi-colors": "^4.1.1"
} }
}, },
"error-ex": { "error-ex": {
@@ -1913,9 +1913,9 @@
} }
}, },
"eslint": { "eslint": {
"version": "7.3.1", "version": "7.4.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.3.1.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.4.0.tgz",
"integrity": "sha512-cQC/xj9bhWUcyi/RuMbRtC3I0eW8MH0jhRELSvpKYkWep3C6YZ2OkvcvJVUeO6gcunABmzptbXBuDoXsjHmfTA==", "integrity": "sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
@@ -2128,14 +2128,6 @@
"acorn": "^7.2.0", "acorn": "^7.2.0",
"acorn-jsx": "^5.2.0", "acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.2.0" "eslint-visitor-keys": "^1.2.0"
},
"dependencies": {
"acorn": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz",
"integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==",
"dev": true
}
} }
}, },
"esprima": { "esprima": {
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "aws-actions-configure-aws-credentials", "name": "aws-actions-configure-aws-credentials",
"version": "1.4.2", "version": "1.4.3",
"description": "Configure AWS Credentials", "description": "Configure AWS Credentials",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -26,11 +26,11 @@
"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.2.4", "@actions/core": "^1.2.4",
"aws-sdk": "^2.707.0" "aws-sdk": "^2.713.0"
}, },
"devDependencies": { "devDependencies": {
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.3.1", "eslint": "^7.4.0",
"jest": "^26.1.0" "jest": "^26.1.0"
} }
} }