fix: action fails when intending to use existing credentials (#796)

* fix: action fails when intending to use existing credentials

* fix: action fails when intending to use existing credentials

* fix: action fails when intending to use existing credentials

* fix: action fails when intending to use existing credentials

* fix: action fails when intending to use existing credentials

* fix: action fails when intending to use existing credentials

---------

Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
This commit is contained in:
Peter Woodworth
2023-08-24 14:38:12 -07:00
committed by GitHub
parent a96263310b
commit 76997ececd
5 changed files with 66 additions and 14 deletions
Generated Vendored
+6 -3
View File
@@ -478,7 +478,8 @@ async function run() {
!AccessKeyId &&
!process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'] &&
!roleChaining) {
core.info('It looks like you might be trying to authenticate with OIDC. Did you mean to set the `id-token` permission?');
core.info('It looks like you might be trying to authenticate with OIDC. Did you mean to set the `id-token` permission? ' +
'If you are not trying to authenticate with OIDC and the action is working successfully, you can ignore this message.');
}
return (!!roleToAssume &&
!!process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'] &&
@@ -519,10 +520,12 @@ async function run() {
// in any error messages.
(0, helpers_1.exportCredentials)({ AccessKeyId, SecretAccessKey, SessionToken });
}
else if (!webIdentityTokenFile && !roleChaining) {
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.');
}
if (AccessKeyId || roleChaining) {
if (AccessKeyId || roleChaining || (process.env['AWS_ACCESS_KEY_ID'] && process.env['AWS_SECRET_ACCESS_KEY'])) {
// 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.