@@ -105,7 +105,7 @@ impl KeeManager {
105105 }
106106
107107 fn add_account ( & self , account_name : & str ) -> io:: Result < bool > {
108- let profile_name = format ! ( "kee-{ account_name}" ) ;
108+ let profile_name = account_name;
109109
110110 println ! ( "\n Starting SSO configuration..." ) ;
111111 println ! ( " (This will open your browser to complete authentication.)" ) ;
@@ -128,7 +128,7 @@ impl KeeManager {
128128
129129 // Run aws configure sso
130130 let status = Command :: new ( "aws" )
131- . args ( [ "configure" , "sso" , "--profile" , & profile_name] )
131+ . args ( [ "configure" , "sso" , "--profile" , profile_name] )
132132 . status ( ) ?;
133133
134134 if !status. success ( ) {
@@ -146,7 +146,7 @@ impl KeeManager {
146146 self . reformat_config_file ( ) ?;
147147
148148 // Read profile info
149- let profile_info = match self . read_profile_info ( & profile_name) {
149+ let profile_info = match self . read_profile_info ( profile_name) {
150150 Some ( info) => info,
151151 None => {
152152 println ! ( " [X] Could not read profile information." ) ;
@@ -162,7 +162,7 @@ impl KeeManager {
162162 self . save_config ( & config) ?;
163163
164164 // Test the profile
165- if self . check_credentials ( & profile_name) {
165+ if self . check_credentials ( profile_name) {
166166 println ! ( "\n [✓] The account was added and is working correctly! — I just tested it." ) ;
167167 } else {
168168 println ! ( "\n [X] I created the profile but credentials may need a refresh..." ) ;
@@ -406,6 +406,7 @@ impl KeeManager {
406406
407407 let account_info = config. accounts . get ( account_name) . unwrap ( ) ;
408408 let profile_name = & account_info. profile_name ;
409+ let profile_region = & account_info. region ;
409410
410411 // Check credentials
411412 if !self . check_credentials ( profile_name) {
@@ -424,7 +425,7 @@ impl KeeManager {
424425 self . save_config ( & config) ?;
425426
426427 // Start subshell
427- self . start_subshell ( account_name, profile_name) ?;
428+ self . start_subshell ( account_name, profile_name, profile_region ) ?;
428429
429430 // Clear current account when subshell exits
430431 config. current_account = None ;
@@ -467,7 +468,12 @@ impl KeeManager {
467468 Ok ( status. success ( ) )
468469 }
469470
470- fn start_subshell ( & self , account_name : & str , profile_name : & str ) -> io:: Result < ( ) > {
471+ fn start_subshell (
472+ & self ,
473+ account_name : & str ,
474+ profile_name : & str ,
475+ profile_region : & str ,
476+ ) -> io:: Result < ( ) > {
471477 // Get current shell
472478 let shell = if cfg ! ( windows) {
473479 env:: var ( "COMSPEC" ) . unwrap_or_else ( |_| "cmd.exe" . to_string ( ) )
@@ -485,6 +491,7 @@ impl KeeManager {
485491 // Start subshell with environment
486492 let mut cmd = Command :: new ( & shell) ;
487493 cmd. env ( "AWS_PROFILE" , profile_name) ;
494+ cmd. env ( "AWS_REGION" , profile_region) ;
488495 cmd. env ( "KEE_CURRENT_ACCOUNT" , account_name) ;
489496 cmd. env ( "KEE_ACTIVE_SESSION" , "1" ) ;
490497
0 commit comments