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
+8 -3
View File
@@ -78,7 +78,8 @@ export async function run() {
!roleChaining
) {
core.info(
'It looks like you might be trying to authenticate with OIDC. Did you mean to set the `id-token` permission?'
'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 (
@@ -127,11 +128,15 @@ 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) {
} 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.