From 59622bc41b5cf71e76d45b97681db298e8230656 Mon Sep 17 00:00:00 2001 From: kuno Date: Tue, 15 Mar 2022 05:49:23 +0800 Subject: [PATCH] fix(aws): Make AWS_REGION orverrides AWS_DEFAULT_REGION (#3619) (#3733) * fix(aws): Make AWS_REGION orverrides AWS_DEFAULT_REGION (#3619) * fix(aws): Align the coding style of region and profile env var (#3619) --- src/modules/aws.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/aws.rs b/src/modules/aws.rs index 9ff03a9c..e63a41c8 100644 --- a/src/modules/aws.rs +++ b/src/modules/aws.rs @@ -64,12 +64,13 @@ fn get_aws_region_from_config(context: &Context, aws_profile: Option<&str>) -> O fn get_aws_profile_and_region(context: &Context) -> (Option, Option) { let profile_env_vars = vec!["AWSU_PROFILE", "AWS_VAULT", "AWSUME_PROFILE", "AWS_PROFILE"]; + let region_env_vars = vec!["AWS_REGION", "AWS_DEFAULT_REGION"]; let profile = profile_env_vars .iter() .find_map(|env_var| context.get_env(env_var)); - let region = context - .get_env("AWS_DEFAULT_REGION") - .or_else(|| context.get_env("AWS_REGION")); + let region = region_env_vars + .iter() + .find_map(|env_var| context.get_env(env_var)); match (profile, region) { (Some(p), Some(r)) => (Some(p), Some(r)), (None, Some(r)) => (None, Some(r)), @@ -285,7 +286,7 @@ mod tests { .collect(); let expected = Some(format!( "on {}", - Color::Yellow.bold().paint("☁️ (ap-northeast-1) ") + Color::Yellow.bold().paint("☁️ (ap-northeast-2) ") )); assert_eq!(expected, actual);