Compare commits

..
Author SHA1 Message Date
Michael Lehmann e10c94a17d reword recommendation 2026-09-11 10:30:36 -07:00
Michael Lehmann f1ab1f0927 chore: update README with warning about pinning to main 2026-09-11 10:15:50 -07:00
7 changed files with 11 additions and 89 deletions

No files matched your search

+6 -19
View File
@@ -5,6 +5,12 @@ Authenticate to AWS in GitHub Actions (and others)! Works especially well with
[secretsmanager]: https://github.com/aws-actions/aws-secretsmanager-get-secrets
_Note: We recommend that you follow
[GitHub's Security Best Practices][ghsecuritybestpractice]
when implementing this action._
[ghsecuritybestpractice]: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions
## Quick Start (OIDC, recommended)
1. Create an IAM Identity Provider in your AWS account for GitHub OIDC. (See
@@ -96,18 +102,9 @@ below).
- Be especially careful about running Actions in non-ephemeral environments, or
[triggering workflows on `pull_request_target`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target)
events.
- Follow [GitHub's security best practices][gh-security] for using third-party
actions.
- Set `translate-env-variables` to false if the [AWS environment variables][env]
or the [action input variables](./README.md#inputs-as-environment-variables)
in your runner are set by other processes to prevent unexpected behavior.
[gh-secrets]:
https://docs.github.com/en/actions/security-guides/encrypted-secrets
[env]:
https://docs.aws.amazon.com/sdkref/latest/guide/settings-reference.html#EVarSettings
[gh-security]:
https://docs.github.com/en/actions/security-guides/security-best-practices-for-github-actions
## Non-OIDC Authentication Options
@@ -197,7 +194,6 @@ detail.
| action-timeout-s | Global timeout for the action in seconds. If set to a value greater than 0, the action will fail if it takes longer than this time to complete. | No |
| no-proxy | Hosts to skip for the proxy configuration. | No |
| sts-endpoint | Custom STS endpoint URL. Use this to point to an STS-compatible API (e.g. MinIO, LocalStack) instead of the default AWS STS endpoint for the region. | No |
| translate-env-variables | Whether to translate AWS environment variables to action inputs. Defaults to true. Translating environment variables automatically may cause unexpected behavior if you have other actions that set AWS environment variables. | No |
</details>
@@ -220,15 +216,6 @@ Sometimes, existing credentials in your runner can get in the way of the
intended outcome. You can set the `unset-current-credentials` input to `true` to
work around this issue.
#### Inputs as environment variables
In addition to using action inputs, this action will read environment variables
to determine its behavior, just like the AWS SDKs do. For example, if you set
`ROLE_TO_ASSUME` in the environment, the action will use that value as if you
had set the `role-to-assume` input. This behavior can be disabled with the
`translate-env-variables` option. The supported list can be found in
[src/helpers.ts](./src/helpers.ts).
#### Configure named AWS profiles
By default, this action exports credentials as environment variables
+1 -4
View File
@@ -104,10 +104,7 @@ inputs:
description: Additional tags to apply to the assumed role session. Must be a JSON object provided as a string.
required: false
sts-endpoint:
description: Custom STS endpoint URL. Use this to point to an STS-compatible API instead of the default AWS STS endpoint for the region.
required: false
translate-env-variables:
description: Whether to translate AWS environment variables to action inputs. Defaults to true. Translating environment variables automatically may cause unexpected behavior if you have other actions that set AWS environment variables.
description: Custom STS endpoint URL. Use this to point to an STS-compatible API (e.g. MinIO, LocalStack) instead of the default AWS STS endpoint for the region.
required: false
outputs:
Generated Vendored
+2 -7
View File
@@ -74025,10 +74025,7 @@ function translateEnvVariables() {
for (const envVar of envVars) {
if (process.env[envVar]) {
const inputKey = `INPUT_${envVar.replace(/_/g, "-")}`;
if (!process.env[inputKey]) {
info(`Translating ${envVar} to input ${envVar.replace(/_/g, "-").toLowerCase()}`);
process.env[inputKey] = process.env[envVar];
}
process.env[inputKey] = process.env[inputKey] || process.env[envVar];
}
}
}
@@ -75938,9 +75935,7 @@ var REGION_REGEX = /^[a-z0-9-]+$/g;
var ROLE_SESSION_NAME_REGEX = /^[\w+=,.@-]*$/;
async function run() {
try {
if (getBooleanInput("translate-env-variables", { required: false, default: true })) {
translateEnvVariables();
}
translateEnvVariables();
const AccessKeyId = getInput("aws-access-key-id", { required: false });
const SecretAccessKey = getInput("aws-secret-access-key", { required: false });
const sessionTokenInput = getInput("aws-session-token", { required: false });
+1 -4
View File
@@ -61,10 +61,7 @@ export function translateEnvVariables() {
for (const envVar of envVars) {
if (process.env[envVar]) {
const inputKey = `INPUT_${envVar.replace(/_/g, '-')}`;
if (!process.env[inputKey]) {
core.info(`Translating ${envVar} to input ${envVar.replace(/_/g, '-').toLowerCase()}`);
process.env[inputKey] = process.env[envVar];
}
process.env[inputKey] = process.env[inputKey] || process.env[envVar];
}
}
}
+1 -3
View File
@@ -25,9 +25,7 @@ const ROLE_SESSION_NAME_REGEX = /^[\w+=,.@-]*$/;
export async function run() {
try {
if (getBooleanInput('translate-env-variables', { required: false, default: true })) {
translateEnvVariables();
}
translateEnvVariables();
// Get inputs
// Undefined inputs are empty strings ( or empty arrays)
const AccessKeyId = core.getInput('aws-access-key-id', { required: false });
-20
View File
@@ -104,26 +104,6 @@ describe('Configure AWS Credentials helpers', {}, () => {
expect(process.env.HTTP_PROXY).toBe('https://proxy:8080');
});
it('logs which environment variables it translates', {}, () => {
delete process.env['INPUT_ROLE-TO-ASSUME'];
process.env.ROLE_TO_ASSUME = 'arn:aws:iam::111111111111:role/ENV-ROLE';
helpers.translateEnvVariables();
expect(core.info).toHaveBeenCalledWith('Translating ROLE_TO_ASSUME to input role-to-assume');
expect(process.env['INPUT_ROLE-TO-ASSUME']).toBe('arn:aws:iam::111111111111:role/ENV-ROLE');
delete process.env.ROLE_TO_ASSUME;
delete process.env['INPUT_ROLE-TO-ASSUME'];
});
it('does not overwrite explicitly set inputs with environment variables', {}, () => {
process.env['INPUT_ROLE-TO-ASSUME'] = 'arn:aws:iam::111111111111:role/EXPLICIT-ROLE';
process.env.ROLE_TO_ASSUME = 'arn:aws:iam::111111111111:role/ENV-ROLE';
helpers.translateEnvVariables();
expect(process.env['INPUT_ROLE-TO-ASSUME']).toBe('arn:aws:iam::111111111111:role/EXPLICIT-ROLE');
expect(core.info).not.toHaveBeenCalledWith('Translating ROLE_TO_ASSUME to input role-to-assume');
delete process.env.ROLE_TO_ASSUME;
delete process.env['INPUT_ROLE-TO-ASSUME'];
});
it('handles getBooleanInput correctly', {}, () => {
vi.spyOn(core, 'getInput').mockReturnValue('true');
expect(helpers.getBooleanInput('test')).toBe(true);
-32
View File
@@ -117,38 +117,6 @@ describe('Configure AWS Credentials', {}, () => {
});
});
describe('Environment variable translation', {}, () => {
beforeEach(() => {
mockedSTSClient.on(GetCallerIdentityCommand).resolvesOnce({ ...mocks.outputs.GET_CALLER_IDENTITY });
// biome-ignore lint/suspicious/noExplicitAny: any required to mock private method
vi.spyOn(CredentialsClient.prototype as any, 'loadCredentials').mockResolvedValueOnce({
accessKeyId: 'MYAWSACCESSKEYID',
});
delete process.env['INPUT_ROLE-TO-ASSUME'];
process.env.ROLE_TO_ASSUME = 'arn:aws:iam::111111111111:role/ENV-ROLE';
});
afterEach(() => {
delete process.env.ROLE_TO_ASSUME;
delete process.env['INPUT_ROLE-TO-ASSUME'];
});
it('translates environment variables to inputs by default', async () => {
vi.mocked(core.getInput).mockImplementation(mocks.getInput(mocks.IAM_USER_INPUTS));
await run();
expect(core.info).toHaveBeenCalledWith('Translating ROLE_TO_ASSUME to input role-to-assume');
expect(process.env['INPUT_ROLE-TO-ASSUME']).toBe('arn:aws:iam::111111111111:role/ENV-ROLE');
expect(core.setFailed).not.toHaveBeenCalled();
});
it('skips translation when translate-env-variables is false', async () => {
vi.mocked(core.getInput).mockImplementation(
mocks.getInput({ ...mocks.IAM_USER_INPUTS, 'translate-env-variables': 'false' }),
);
await run();
expect(core.info).not.toHaveBeenCalledWith('Translating ROLE_TO_ASSUME to input role-to-assume');
expect(process.env['INPUT_ROLE-TO-ASSUME']).toBeUndefined();
expect(core.setFailed).not.toHaveBeenCalled();
});
});
describe('AssumeRole with IAM LTC', {}, () => {
beforeEach(() => {
vi.mocked(core.getInput).mockImplementation(mocks.getInput(mocks.IAM_ASSUMEROLE_INPUTS));