@@ -849,18 +849,17 @@ describe("credential-provider-node integration test", () => {
849849 } ) ;
850850 } ) ;
851851
852- it ( "fromIni assumeRole provider should use the caller client's region for STS" , async ( ) => {
852+ it ( "fromIni assumeRole provider should use the caller client's region for STS if profile does not set region " , async ( ) => {
853853 sts = new STS ( {
854854 region : "eu-west-1" ,
855- credentials : fromIni ( ) ,
855+ credentials : fromIni ( { } ) ,
856856 } ) ;
857857 iniProfileData . assume = {
858- region : "eu-west-1" ,
859858 aws_access_key_id : "ASSUME_STATIC_ACCESS_KEY" ,
860859 aws_secret_access_key : "ASSUME_STATIC_SECRET_KEY" ,
861860 } ;
861+ delete iniProfileData . default . region ;
862862 Object . assign ( iniProfileData . default , {
863- region : "eu-west-1" ,
864863 role_arn : "ROLE_ARN" ,
865864 role_session_name : "ROLE_SESSION_NAME" ,
866865 external_id : "EXTERNAL_ID" ,
@@ -881,6 +880,37 @@ describe("credential-provider-node integration test", () => {
881880 } ) ;
882881 } ) ;
883882
883+ it ( "fromIni assumeRole provider should prefer profile region for STS" , async ( ) => {
884+ sts = new STS ( {
885+ region : "eu-west-1" ,
886+ credentials : fromIni ( { } ) ,
887+ } ) ;
888+ iniProfileData . assume = {
889+ aws_access_key_id : "ASSUME_STATIC_ACCESS_KEY" ,
890+ aws_secret_access_key : "ASSUME_STATIC_SECRET_KEY" ,
891+ } ;
892+ Object . assign ( iniProfileData . default , {
893+ region : "eu-west-2" ,
894+ role_arn : "ROLE_ARN" ,
895+ role_session_name : "ROLE_SESSION_NAME" ,
896+ external_id : "EXTERNAL_ID" ,
897+ source_profile : "assume" ,
898+ } ) ;
899+ await sts . getCallerIdentity ( { } ) ;
900+ const credentials = await sts . config . credentials ( ) ;
901+ expect ( credentials ) . toEqual ( {
902+ accessKeyId : "STS_AR_ACCESS_KEY_ID" ,
903+ secretAccessKey : "STS_AR_SECRET_ACCESS_KEY" ,
904+ sessionToken : "STS_AR_SESSION_TOKEN_eu-west-2" ,
905+ expiration : new Date ( "3000-01-01T00:00:00.000Z" ) ,
906+ $source : {
907+ CREDENTIALS_CODE : "e" ,
908+ CREDENTIALS_PROFILE_SOURCE_PROFILE : "o" ,
909+ CREDENTIALS_STS_ASSUME_ROLE : "i" ,
910+ } ,
911+ } ) ;
912+ } ) ;
913+
884914 it ( "fromWebToken provider should use caller client region" , async ( ) => {
885915 sts = new STS ( {
886916 region : "ap-northeast-1" ,
0 commit comments