From 3ffd03a59c8a25fca6012ceb55877adce3edbb8a Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Fri, 19 Sep 2025 15:02:15 +0100 Subject: [PATCH] fix(aws): set region from default profile By default when there is no region set: ``` $ asp $ env | grep -i aws AWS_DEFAULT_PROFILE= AWS_PROFILE= AWS_EB_PROFILE= AWS_REGION= AWS_DEFAULT_REGION= ``` we get this error for this command if we are using regional STS endpoints: ``` $ aws sts get-caller-identity | jq .Arn Invalid endpoint: https://sts..amazonaws.com ``` This PR ensures that a default region is always set. By default comes from `default` profile configuration, and defaults to `us-east-1` --- plugins/aws/aws.plugin.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 0c43031df..58adfc770 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -43,6 +43,14 @@ function asp() { export AWS_EB_PROFILE=$1 export AWS_PROFILE_REGION=$(aws configure get region) + if [[ -z "${AWS_PROFILE_REGION}" ]]; then + if [[ -z "${available_profiles[(r)default]}" ]]; then + echo "region defaulting to us-east-1" + else + export AWS_PROFILE_REGION=$(aws configure get region --profile default) + fi + fi + export AWS_REGION=$AWS_PROFILE_REGION _aws_update_state