@@ -30,7 +30,16 @@ import { showAmazonQWalkthroughOnce } from '../../amazonq/onboardingPage/walkthr
3030import { setContext } from '../../shared/vscode/setContext'
3131import { openUrl } from '../../shared/utilities/vsCodeUtils'
3232import { telemetry } from '../../shared/telemetry/telemetry'
33- import { AuthStateEvent , cacheChangedEvent , stsCacheChangedEvent , LanguageClientAuth , Login , SsoLogin , IamLogin , LoginTypes } from '../../auth/auth2'
33+ import {
34+ AuthStateEvent ,
35+ cacheChangedEvent ,
36+ stsCacheChangedEvent ,
37+ LanguageClientAuth ,
38+ Login ,
39+ SsoLogin ,
40+ IamLogin ,
41+ LoginTypes ,
42+ } from '../../auth/auth2'
3443import { builderIdStartUrl , internalStartUrl } from '../../auth/sso/constants'
3544import { VSCODE_EXTENSION_ID } from '../../shared/extensions'
3645import { RegionProfileManager } from '../region/regionProfileManager'
@@ -64,7 +73,14 @@ export interface IAuthProvider {
6473 getToken ( ) : Promise < string >
6574 getIamCredential ( ) : Promise < IamCredentials >
6675 readonly profileName : string
67- readonly connection ?: { startUrl ?: string ; region ?: string ; accessKey ?: string ; secretKey ?: string ; sessionToken ?: string }
76+ readonly connection ?: {
77+ startUrl ?: string
78+ region ?: string
79+ accessKey ?: string
80+ secretKey ?: string
81+ sessionToken ?: string
82+ roleArn ?: string
83+ }
6884}
6985
7086/**
@@ -175,13 +191,23 @@ export class AuthUtil implements IAuthProvider {
175191 }
176192
177193 // Log in using IAM or STS credentials
178- async login_iam ( accessKey : string , secretKey : string , sessionToken ?: string , roleArn ?: string ) : Promise < GetIamCredentialResult | undefined > {
194+ async login_iam (
195+ accessKey : string ,
196+ secretKey : string ,
197+ sessionToken ?: string ,
198+ roleArn ?: string
199+ ) : Promise < GetIamCredentialResult | undefined > {
179200 let response : GetIamCredentialResult | undefined
180201 // Create IAM login session
181202 if ( ! this . isIamSession ( ) ) {
182203 this . session = new IamLogin ( this . profileName , this . lspAuth , this . eventEmitter )
183204 }
184- response = await ( this . session as IamLogin ) . login ( { accessKey : accessKey , secretKey : secretKey , sessionToken : sessionToken , roleArn : roleArn } )
205+ response = await ( this . session as IamLogin ) . login ( {
206+ accessKey : accessKey ,
207+ secretKey : secretKey ,
208+ sessionToken : sessionToken ,
209+ roleArn : roleArn ,
210+ } )
185211 await showAmazonQWalkthroughOnce ( )
186212 return response
187213 }
@@ -375,10 +401,9 @@ export class AuthUtil implements IAuthProvider {
375401
376402 private async refreshState ( state = this . getAuthState ( ) ) {
377403 if ( state === 'expired' || state === 'notConnected' ) {
378- if ( this . isSsoSession ( ) ) {
404+ if ( this . isSsoSession ( ) ) {
379405 this . lspAuth . deleteBearerToken ( )
380- }
381- else if ( this . isIamSession ( ) ) {
406+ } else if ( this . isIamSession ( ) ) {
382407 this . lspAuth . deleteIamCredential ( )
383408 }
384409 if ( this . isIdcConnection ( ) ) {
@@ -440,6 +465,8 @@ export class AuthUtil implements IAuthProvider {
440465 } else if ( this . isIamSession ( ) ) {
441466 return {
442467 credentialSourceId : 'sharedCredentials' ,
468+ credentialAccessKey : AuthUtil . instance . connection ?. accessKey ,
469+ credentialRoleArn : AuthUtil . instance . connection ?. roleArn ,
443470 }
444471 }
445472
0 commit comments