diff --git a/src/auth/awsclient.ts b/src/auth/awsclient.ts index 561954bb..5a06c7f7 100644 --- a/src/auth/awsclient.ts +++ b/src/auth/awsclient.ts @@ -356,21 +356,19 @@ export class AwsClient extends BaseExternalAccountClient { return process.env['AWS_REGION'] || process.env['AWS_DEFAULT_REGION']; } - private get securityCredentialsFromEnvironment(): - | AwsSecurityCredentialsFromEnvironment - | undefined { - let awsSecurityCredentials; - // Check if both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are available. + private get securityCredentialsFromEnv(): AwsSecurityCredentials | null { + // Both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required. if ( process.env['AWS_ACCESS_KEY_ID'] && process.env['AWS_SECRET_ACCESS_KEY'] ) { - awsSecurityCredentials = { + return { accessKeyId: process.env['AWS_ACCESS_KEY_ID'], secretAccessKey: process.env['AWS_SECRET_ACCESS_KEY'], token: process.env['AWS_SESSION_TOKEN'], }; } - return awsSecurityCredentials; + + return null; } }