fix: validation logic throwing unwanted errors (#818)

* fix: throws error even when valid credentials are present

* fix: throws error when invalid credentials are present despite not wanting to use them
This commit is contained in:
Peter Woodworth
2023-09-05 14:19:05 -07:00
committed by GitHub
parent 6c962b9fd3
commit d78f55b1db
4 changed files with 42 additions and 16 deletions
+5 -7
View File
@@ -128,15 +128,13 @@ export async function run() {
// the source credentials to already be masked as secrets
// in any error messages.
exportCredentials({ AccessKeyId, SecretAccessKey, SessionToken });
} else if (
!webIdentityTokenFile &&
!roleChaining &&
!(process.env['AWS_ACCESS_KEY_ID'] && process.env['AWS_SECRET_ACCESS_KEY'])
) {
throw new Error('Could not determine how to assume credentials. Please check your inputs and try again.');
} else if (!webIdentityTokenFile && !roleChaining) {
// Proceed only if credentials can be picked up
await credentialsClient.validateCredentials();
sourceAccountId = await exportAccountId(credentialsClient, maskAccountId);
}
if (AccessKeyId || roleChaining || (process.env['AWS_ACCESS_KEY_ID'] && process.env['AWS_SECRET_ACCESS_KEY'])) {
if (AccessKeyId || roleChaining) {
// Validate that the SDK can actually pick up credentials.
// This validates cases where this action is using existing environment credentials,
// and cases where the user intended to provide input credentials but the secrets inputs resolved to empty strings.