Compare commits

...

22 Commits

Author SHA1 Message Date
AWS SDKs and Tools bot ececac1a45 chore(main): release 4.1.0 (#1282)
Co-authored-by: Michael Lehmann <lehmanmj@amazon.com>
2025-02-10 15:09:08 -08:00
GitHub Actions 16fec6080f chore: Update dist 2025-02-08 00:25:25 +00:00
Michael Lehmann eb70354fb4 feat: idempotent fetch (#1289)
* Add functionality to re-use existing credentials

* Finish adding use-existing-credentials logic

* Add testing for use-existing-credentials

* Update README

* feat: finalize use-exisiting-credentials feature

---------

Co-authored-by: Tom Keller <kellertk@amazon.com>
2025-02-07 16:24:45 -08:00
dependabot[bot] 3478c15aa1 chore(deps-dev): bump memfs from 4.14.0 to 4.17.0 (#1250)
Bumps [memfs](https://github.com/streamich/memfs) from 4.14.0 to 4.17.0.
- [Release notes](https://github.com/streamich/memfs/releases)
- [Changelog](https://github.com/streamich/memfs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/streamich/memfs/compare/v4.14.0...v4.17.0)

---
updated-dependencies:
- dependency-name: memfs
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
2025-02-05 01:22:06 +00:00
GitHub Actions a69d38c39d chore: Update dist 2025-02-05 01:20:28 +00:00
dependabot[bot] 6b1d0f829d chore(deps-dev): bump @smithy/property-provider from 3.1.8 to 4.0.1 (#1246)
Bumps [@smithy/property-provider](https://github.com/awslabs/smithy-typescript/tree/HEAD/packages/property-provider) from 3.1.8 to 4.0.1.
- [Release notes](https://github.com/awslabs/smithy-typescript/releases)
- [Changelog](https://github.com/smithy-lang/smithy-typescript/blob/main/packages/property-provider/CHANGELOG.md)
- [Commits](https://github.com/awslabs/smithy-typescript/commits/@smithy/property-provider@4.0.1/packages/property-provider)

---
updated-dependencies:
- dependency-name: "@smithy/property-provider"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
2025-02-05 01:19:53 +00:00
Tom Keller f021516513 chore: remove role session name 2025-02-04 17:18:15 -08:00
dependabot[bot] 1c8dbbcc02 chore(deps-dev): bump @vercel/ncc from 0.38.2 to 0.38.3 (#1204)
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.38.2 to 0.38.3.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.38.2...0.38.3)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
2025-02-05 01:13:40 +00:00
Tom Keller ce290d67fe chore: change dependabot role session name 2025-02-04 17:12:00 -08:00
Tom Keller 1780ebd97b chore: create one-off test for CAWSC 2025-02-04 17:06:10 -08:00
GitHub Actions a02ef26683 chore: Update dist 2025-02-05 00:30:13 +00:00
dependabot[bot] 5fbd2e409b chore(deps-dev): bump typescript from 5.6.3 to 5.7.3 (#1247)
Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.6.3 to 5.7.3.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.6.3...v5.7.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Lehmann <lehmanmj@amazon.com>
2025-02-05 00:29:37 +00:00
Michael Lehmann f0af89b102 fix: Dependabot autoapprove id-token write permission (#1285)
* Fix automerge action syntax

* Fix typo

* Fix typo

* Add brackets

* add ID token permission

---------

Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
2025-02-05 00:27:51 +00:00
Michael Lehmann b9ee51dc60 fix: Dependabot autoapprove (#1284)
* Fix automerge action syntax

* Fix typo

* Fix typo

* Add brackets
2025-02-05 00:23:12 +00:00
GitHub Actions 66c00faf39 chore: Update dist 2025-02-04 23:06:04 +00:00
Tom Keller 134d71efe0 fix: build failure due to tests (#1283) 2025-02-04 15:05:30 -08:00
dependabot[bot] b8ef615781 chore(deps): bump undici from 5.28.4 to 5.28.5 (#1271)
Bumps [undici](https://github.com/nodejs/undici) from 5.28.4 to 5.28.5.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.28.4...v5.28.5)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-04 14:34:15 -08:00
dependabot[bot] e5b9735585 chore(deps-dev): bump @types/node from 22.9.0 to 22.13.1 (#1277)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.9.0 to 22.13.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-04 14:30:57 -08:00
dependabot[bot] 79ebbb3141 chore(deps): bump @aws-sdk/client-sts from 3.682.0 to 3.741.0 (#1278)
Bumps [@aws-sdk/client-sts](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-sts) from 3.682.0 to 3.741.0.
- [Release notes](https://github.com/aws/aws-sdk-js-v3/releases)
- [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-sts/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.741.0/clients/client-sts)

---
updated-dependencies:
- dependency-name: "@aws-sdk/client-sts"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-04 14:18:13 -08:00
dependabot[bot] 7f029f3507 chore(deps-dev): bump vitest and @vitest/coverage-v8
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) and [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8). These dependencies needed to be updated together.

Updates `vitest` from 2.1.4 to 2.1.9
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.9/packages/vitest)

Updates `@vitest/coverage-v8` from 2.1.4 to 2.1.9
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.9/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
- dependency-name: "@vitest/coverage-v8"
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-04 14:15:29 -08:00
Michael Lehmann 39fd91c08e fix: typo (#1281)
* Fix automerge action syntax

* Fix typo

---------

Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
2025-02-04 22:10:35 +00:00
Michael Lehmann cf624fbdad Fix automerge action syntax 2025-02-04 12:02:34 -08:00
24 changed files with 8970 additions and 13893 deletions
+1 -4
View File
@@ -9,10 +9,7 @@ jobs:
contents: write
pull-requests: write
id-token: write
if: >-
github.event.review.state == 'approved' &&
github.event.repository == 'aws/configure-aws-credentials' &&
(github.event.review.author_association == 'OWNER' || github.event.review.user.login == 'aws-sdk-osds')
if: ${{ github.event.review.state == 'approved' && github.repository == 'aws-actions/configure-aws-credentials' && (github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.user.login == 'aws-sdk-osds') }}
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
+20
View File
@@ -0,0 +1,20 @@
name: Test Configure AWS Credential
on:
workflow_dispatch:
jobs:
cawsc:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: CAWSC
uses: aws-actions/configure-aws-credentials@main
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
role-duration-seconds: 900
role-session-name: TestCAWSC
- name: Whoami
run: |
aws sts get-caller-identity
+2 -2
View File
@@ -2,10 +2,11 @@ name: Dependabot auto-approve
on: pull_request
permissions:
pull-requests: write
id-token: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'aws/configure-aws-credentials'
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'aws-actions/configure-aws-credentials' }}
steps:
- name: Get Metadata
id: dependabot-metadata
@@ -18,7 +19,6 @@ jobs:
aws-region: us-west-2
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
role-duration-seconds: 900
role-session-name: SecretsManagerFetch
- name: Get bot user token
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
+1 -1
View File
@@ -1,5 +1,5 @@
{
".release-please-manifest.json": "4.0.2",
"package.json": "4.0.2",
".": "4.0.3"
".": "4.1.0"
}
+15
View File
@@ -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.
## [4.1.0](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.3...v4.1.0) (2025-02-08)
### Features
* idempotent fetch ([#1289](https://github.com/aws-actions/configure-aws-credentials/issues/1289)) ([eb70354](https://github.com/aws-actions/configure-aws-credentials/commit/eb70354fb423a380b6e4ab4b9f15d2ee9ffae911))
### Bug Fixes
* build failure due to tests ([#1283](https://github.com/aws-actions/configure-aws-credentials/issues/1283)) ([134d71e](https://github.com/aws-actions/configure-aws-credentials/commit/134d71efe0ecbe9ad6965f2f766c0cae63a7685f))
* Dependabot autoapprove ([#1284](https://github.com/aws-actions/configure-aws-credentials/issues/1284)) ([b9ee51d](https://github.com/aws-actions/configure-aws-credentials/commit/b9ee51dc600fe38c892e24f60ca26476e0e0b6de))
* Dependabot autoapprove id-token write permission ([#1285](https://github.com/aws-actions/configure-aws-credentials/issues/1285)) ([f0af89b](https://github.com/aws-actions/configure-aws-credentials/commit/f0af89b102390dcf10ce402195d74a98f24861f3))
* typo ([#1281](https://github.com/aws-actions/configure-aws-credentials/issues/1281)) ([39fd91c](https://github.com/aws-actions/configure-aws-credentials/commit/39fd91c08ed8bf770034de4e62662503e8007d76))
## [4.0.3](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.2...v4.0.3) (2025-01-27)
+1
View File
@@ -116,6 +116,7 @@ See [action.yml](./action.yml) for more detail.
| disable-retry | Disabled retry/backoff logic for assume role calls. By default, retries are enabled. | No |
| retry-max-attempts | Limits the number of retry attempts before giving up. Defaults to 12. | No |
| special-characters-workaround | Uncommonly, some environments cannot tolerate special characters in a secret key. This option will retry fetching credentials until the secret access key does not contain special characters. This option overrides disable-retry and retry-max-attempts. | No |
| use-existing-credentials | When set, the action will check if existing credentials are valid and exit if they are. Defaults to false. | No |
#### Credential Lifetime
The default session duration is **1 hour**.
+2
View File
@@ -73,6 +73,8 @@ inputs:
special-characters-workaround:
description: Some environments do not support special characters in AWS_SECRET_ACCESS_KEY. This option will retry fetching credentials until the secret access key does not contain special characters. This option overrides disable-retry and retry-max-attempts. This option is disabled by default
required: false
use-existing-credentials:
description: When enabled, this option will check if there are already valid credentials in the environment. If there are, new credentials will not be fetched. If there are not, the action will run as normal.
outputs:
aws-account-id:
description: The AWS account ID for the provided credentials
+14
View File
@@ -0,0 +1,14 @@
import { STSClient } from '@aws-sdk/client-sts';
export interface CredentialsClientProps {
region?: string;
proxyServer?: string;
}
export declare class CredentialsClient {
region?: string;
private _stsClient?;
private readonly requestHandler?;
constructor(props: CredentialsClientProps);
get stsClient(): STSClient;
validateCredentials(expectedAccessKeyId?: string, roleChaining?: boolean): Promise<void>;
private loadCredentials;
}
+17
View File
@@ -0,0 +1,17 @@
import type { CredentialsClient } from './CredentialsClient';
export interface assumeRoleParams {
credentialsClient: CredentialsClient;
roleToAssume: string;
roleDuration: number;
roleSessionName: string;
roleSkipSessionTagging?: boolean;
sourceAccountId?: string;
roleExternalId?: string;
webIdentityTokenFile?: string;
webIdentityToken?: string;
inlineSessionPolicy?: string;
managedSessionPolicies?: {
arn: string;
}[];
}
export declare function assumeRole(params: assumeRoleParams): Promise<import("@aws-sdk/client-sts").AssumeRoleCommandOutput>;
+11
View File
@@ -0,0 +1,11 @@
/**
* When the GitHub Actions job is done, clean up any environment variables that
* may have been set by the configure-aws-credentials steps in the job.
*
* Environment variables are not intended to be shared across different jobs in
* the same GitHub Actions workflow: GitHub Actions documentation states that
* each job runs in a fresh instance. However, doing our own cleanup will
* give us additional assurance that these environment variables are not shared
* with any other jobs.
*/
export declare function cleanup(): void;
Generated Vendored
+17
View File
@@ -0,0 +1,17 @@
import type { Credentials } from '@aws-sdk/client-sts';
import type { CredentialsClient } from './CredentialsClient';
export declare function exportCredentials(creds?: Partial<Credentials>, outputCredentials?: boolean): void;
export declare function unsetCredentials(): void;
export declare function exportRegion(region: string): void;
export declare function exportAccountId(credentialsClient: CredentialsClient, maskAccountId?: boolean): Promise<string>;
export declare function sanitizeGitHubVariables(name: string): string;
export declare function defaultSleep(ms: number): Promise<unknown>;
declare let sleep: typeof defaultSleep;
export declare function withsleep(s: typeof sleep): void;
export declare function reset(): void;
export declare function verifyKeys(creds: Partial<Credentials> | undefined): boolean;
export declare function retryAndBackoff<T>(fn: () => Promise<T>, isRetryable: boolean, maxRetries?: number, retries?: number, base?: number): Promise<T>;
export declare function errorMessage(error: unknown): string;
export declare function isDefined<T>(i: T | undefined | null): i is T;
export declare function areCredentialsValid(credentialsClient: CredentialsClient): Promise<boolean>;
export {};
Generated Vendored
+1
View File
@@ -0,0 +1 @@
export declare function run(): Promise<void>;
Generated Vendored
+4313 -6110
View File
File diff suppressed because it is too large Load Diff
Generated Vendored
+3679 -6772
View File
File diff suppressed because it is too large Load Diff
+804 -981
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -1,9 +1,9 @@
{
"name": "configure-aws-credentials",
"description": "A GitHub Action to configure AWS credentials",
"version": "4.0.3",
"version": "4.1.0",
"scripts": {
"build": "tsc --project tsconfig.build.json",
"build": "tsc",
"lint": "biome check --error-on-warnings ./src",
"package": "npm run build && ncc build --license THIRD-PARTY -o dist && ncc build src/cleanup/index.ts -o dist/cleanup && cpy dist/THIRD-PARTY . && del-cli dist/THIRD-PARTY",
"test": "npm run lint && vitest run"
@@ -16,22 +16,22 @@
"devDependencies": {
"@aws-sdk/credential-provider-env": "^3.515.0",
"@biomejs/biome": "1.9.4",
"@smithy/property-provider": "^3.1.7",
"@types/node": "^22.9.0",
"@vercel/ncc": "^0.38.2",
"@vitest/coverage-v8": "^2.1.3",
"@smithy/property-provider": "^4.0.1",
"@types/node": "^22.13.1",
"@vercel/ncc": "^0.38.3",
"@vitest/coverage-v8": "^2.1.9",
"aws-sdk-client-mock": "^4.1.0",
"cpy-cli": "^5.0.0",
"del-cli": "^6.0.0",
"json-schema": "^0.4.0",
"memfs": "^4.14.0",
"memfs": "^4.17.0",
"standard-version": "^9.5.0",
"typescript": "^5.6.3",
"vitest": "^2.1.3"
"typescript": "^5.7.3",
"vitest": "^2.1.9"
},
"dependencies": {
"@actions/core": "^1.11.1",
"@aws-sdk/client-sts": "^3.675.0",
"@aws-sdk/client-sts": "^3.741.0",
"@smithy/node-http-handler": "^4.0.1",
"https-proxy-agent": "^5.0.1"
},
+13
View File
@@ -144,3 +144,16 @@ export function isDefined<T>(i: T | undefined | null): i is T {
return i !== undefined && i !== null;
}
/* c8 ignore stop */
export async function areCredentialsValid(credentialsClient: CredentialsClient) {
const client = credentialsClient.stsClient;
try {
const identity = await client.send(new GetCallerIdentityCommand({}));
if (identity.Account) {
return true;
}
return false;
} catch (_) {
return false;
}
}
+13
View File
@@ -3,6 +3,7 @@ import type { AssumeRoleCommandOutput } from '@aws-sdk/client-sts';
import { CredentialsClient } from './CredentialsClient';
import { assumeRole } from './assumeRole';
import {
areCredentialsValid,
errorMessage,
exportAccountId,
exportCredentials,
@@ -60,6 +61,8 @@ export async function run() {
const specialCharacterWorkaroundInput =
core.getInput('special-characters-workaround', { required: false }) || 'false';
const specialCharacterWorkaround = specialCharacterWorkaroundInput.toLowerCase() === 'true';
const useExistingCredentialsInput = core.getInput('use-existing-credentials', { required: false }) || 'false';
const useExistingCredentials = useExistingCredentialsInput.toLowerCase() === 'true';
let maxRetries = Number.parseInt(core.getInput('retry-max-attempts', { required: false })) || 12;
switch (true) {
case specialCharacterWorkaround:
@@ -116,6 +119,16 @@ export async function run() {
let sourceAccountId: string;
let webIdentityToken: string;
//if the user wants to attempt to use existing credentials, check if we have some already
if (useExistingCredentials) {
const validCredentials = await areCredentialsValid(credentialsClient);
if (validCredentials) {
core.notice('Pre-existing credentials are valid. No need to generate new ones.');
return;
}
core.notice('No valid credentials exist. Running as normal.');
}
// If OIDC is being used, generate token
// Else, export credentials provided as input
if (useGitHubOIDCProvider()) {
+13
View File
@@ -27,6 +27,7 @@ describe('Configure AWS Credentials', {}, () => {
vi.spyOn(core, 'setOutput').mockImplementation((_n, _v) => {});
vi.spyOn(core, 'debug').mockImplementation((_m) => {});
vi.spyOn(core, 'info').mockImplementation((_m) => {});
vi.spyOn(core, 'notice').mockImplementation((_m) => {});
// Remove any existing environment variables before each test to prevent the
// SDK from picking them up
process.env = { ...mocks.envs };
@@ -299,5 +300,17 @@ describe('Configure AWS Credentials', {}, () => {
await run();
expect(core.setFailed).toHaveBeenCalled();
});
it('gets new creds if told to reuse existing but they\'re invalid', {}, async () => {
vi.spyOn(core, 'getInput').mockImplementation(mocks.getInput(mocks.USE_EXISTING_CREDENTIALS_INPUTS));
mockedSTSClient.on(GetCallerIdentityCommand).rejects();
await run();
expect(core.notice).toHaveBeenCalledWith('No valid credentials exist. Running as normal.')
});
it('doesn\'t get new creds if there are already valid ones and we said use them', {}, async () => {
vi.spyOn(core, 'getInput').mockImplementation(mocks.getInput(mocks.USE_EXISTING_CREDENTIALS_INPUTS));
mockedSTSClient.on(GetCallerIdentityCommand).resolves(mocks.outputs.GET_CALLER_IDENTITY);
await run();
expect(core.setFailed).not.toHaveBeenCalled();
})
});
});
+5
View File
@@ -27,6 +27,11 @@ const inputs = {
'role-chaining': 'true',
'aws-region': 'fake-region-1',
},
USE_EXISTING_CREDENTIALS_INPUTS: {
'aws-region': 'fake-region-1',
'use-existing-credentials': 'true',
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
}
};
const envs = {
-9
View File
@@ -1,9 +0,0 @@
{
"extends": "./tsconfig.json",
"exclude": [
"test/**/*.ts"
],
"compilerOptions": {
"rootDir": "src"
},
}
+6 -4
View File
@@ -22,12 +22,14 @@
"lib": [ "ES2020" ],
"target": "ES2020",
"noErrorTruncation": true,
"esModuleInterop": true
"esModuleInterop": true,
"rootDir": "src",
},
"include": [
"src/**/*.ts",
"test/**/*.test.ts"
"src/**/*.ts"
],
"exclude": [
"test/**/*.ts"
],
"exclude": [],
}
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"include": [
"test/**/*.ts",
"src/**/*.ts"
],
"exclude": [],
"compilerOptions": {
"rootDir": "./"
},
}
+1
View File
@@ -5,5 +5,6 @@ export default defineConfig({
passWithNoTests: true,
include: ['test/**/*.test.ts'],
coverage: { enabled: true },
typecheck: { tsconfig: './tsconfig.test.json' },
},
});