fix to make action still run

This commit is contained in:
Michael Lehmann
2025-06-04 15:45:40 -07:00
committed by kellertk
parent a26a7d8191
commit e378c2d267
6 changed files with 7 additions and 15 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ See [action.yml](./action.yml) for more detail.
| inline-session-policy | You may further restrict the assumed role policy by defining an inline policy here. | No | | inline-session-policy | You may further restrict the assumed role policy by defining an inline policy here. | No |
| managed-session-policies | You may further restrict the assumed role policy by specifying a managed policy here. | No | | managed-session-policies | You may further restrict the assumed role policy by specifying a managed policy here. | No |
| output-credentials | When set, outputs fetched credentials as action step output. (Outputs access-key-id, secret-access-key, session-token, and expiration). Defaults to false. | No | | output-credentials | When set, outputs fetched credentials as action step output. (Outputs access-key-id, secret-access-key, session-token, and expiration). Defaults to false. | No |
| output-env-credentials | When set, exports fetched credentials as environment variables (AWS_REGION, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN). Defaults to true. Set to false if you need to avoid setting/changing env variables. (You'd probably want to use output-credentials if you disable this). | No | | output-env-credentials | When set, outputs fetched credentials as environment variables (AWS_REGION, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN). Defaults to true. Set to false if you need to avoid setting/changing env variables. You'd probably want to use output-credentials if you disable this. (NOTE: Setting to false will prevent the aws-account-id from being exported as a step output). | No |
| unset-current-credentials | When set, attempts to unset any existing credentials in your action runner. | No | | unset-current-credentials | When set, attempts to unset any existing credentials in your action runner. | No |
| disable-retry | Disabled retry/backoff logic for assume role calls. By default, retries are enabled. | No | | 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 | | retry-max-attempts | Limits the number of retry attempts before giving up. Defaults to 12. | No |
Generated Vendored
-2
View File
@@ -46372,9 +46372,7 @@ function exportRegion(region, outputEnvCredentials) {
// Obtains account ID from STS Client and sets it as output // Obtains account ID from STS Client and sets it as output
async function exportAccountId(credentialsClient, maskAccountId) { async function exportAccountId(credentialsClient, maskAccountId) {
const client = credentialsClient.stsClient; const client = credentialsClient.stsClient;
core.info('trying to get account id');
const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({})); const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
core.info('got account id');
const accountId = identity.Account; const accountId = identity.Account;
if (!accountId) { if (!accountId) {
throw new Error('Could not get Account ID from STS. Did you set credentials?'); throw new Error('Could not get Account ID from STS. Did you set credentials?');
Generated Vendored
+3 -6
View File
@@ -55,7 +55,6 @@ class CredentialsClient {
} }
} }
async loadCredentials() { async loadCredentials() {
(0, core_1.info)('trying to load credentials');
const client = new client_sts_1.STSClient({ const client = new client_sts_1.STSClient({
requestHandler: this.requestHandler ? this.requestHandler : undefined, requestHandler: this.requestHandler ? this.requestHandler : undefined,
}); });
@@ -366,9 +365,7 @@ function exportRegion(region, outputEnvCredentials) {
// Obtains account ID from STS Client and sets it as output // Obtains account ID from STS Client and sets it as output
async function exportAccountId(credentialsClient, maskAccountId) { async function exportAccountId(credentialsClient, maskAccountId) {
const client = credentialsClient.stsClient; const client = credentialsClient.stsClient;
core.info('trying to get account id');
const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({})); const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
core.info('got account id');
const accountId = identity.Account; const accountId = identity.Account;
if (!accountId) { if (!accountId) {
throw new Error('Could not get Account ID from STS. Did you set credentials?'); throw new Error('Could not get Account ID from STS. Did you set credentials?');
@@ -670,9 +667,9 @@ async function run() {
if (!process.env.GITHUB_ACTIONS || AccessKeyId) { if (!process.env.GITHUB_ACTIONS || AccessKeyId) {
await credentialsClient.validateCredentials(roleCredentials.Credentials?.AccessKeyId); await credentialsClient.validateCredentials(roleCredentials.Credentials?.AccessKeyId);
} }
core.info(`validated credentials`); if (outputEnvCredentials) {
await (0, helpers_1.exportAccountId)(credentialsClient, maskAccountId); await (0, helpers_1.exportAccountId)(credentialsClient, maskAccountId);
core.info(`exported account id`); }
} }
else { else {
core.info('Proceeding with IAM user credentials'); core.info('Proceeding with IAM user credentials');
-1
View File
@@ -63,7 +63,6 @@ export class CredentialsClient {
} }
private async loadCredentials() { private async loadCredentials() {
info('trying to load credentials');
const client = new STSClient({ const client = new STSClient({
requestHandler: this.requestHandler ? this.requestHandler : undefined, requestHandler: this.requestHandler ? this.requestHandler : undefined,
}); });
-2
View File
@@ -96,9 +96,7 @@ export function exportRegion(region: string, outputEnvCredentials?: boolean) {
// Obtains account ID from STS Client and sets it as output // Obtains account ID from STS Client and sets it as output
export async function exportAccountId(credentialsClient: CredentialsClient, maskAccountId?: boolean) { export async function exportAccountId(credentialsClient: CredentialsClient, maskAccountId?: boolean) {
const client = credentialsClient.stsClient; const client = credentialsClient.stsClient;
core.info('trying to get account id');
const identity = await client.send(new GetCallerIdentityCommand({})); const identity = await client.send(new GetCallerIdentityCommand({}));
core.info('got account id');
const accountId = identity.Account; const accountId = identity.Account;
if (!accountId) { if (!accountId) {
throw new Error('Could not get Account ID from STS. Did you set credentials?'); throw new Error('Could not get Account ID from STS. Did you set credentials?');
+3 -3
View File
@@ -205,9 +205,9 @@ export async function run() {
if (!process.env.GITHUB_ACTIONS || AccessKeyId) { if (!process.env.GITHUB_ACTIONS || AccessKeyId) {
await credentialsClient.validateCredentials(roleCredentials.Credentials?.AccessKeyId); await credentialsClient.validateCredentials(roleCredentials.Credentials?.AccessKeyId);
} }
core.info(`validated credentials`); if (outputEnvCredentials) {
await exportAccountId(credentialsClient, maskAccountId); await exportAccountId(credentialsClient, maskAccountId);
core.info(`exported account id`); }
} else { } else {
core.info('Proceeding with IAM user credentials'); core.info('Proceeding with IAM user credentials');
} }