fix(aws): pass default region to fetch regions (#12175)

Co-authored-by: Gauthier Delacroix <no@email.com>
This commit is contained in:
Gauthier Delacroix 2024-01-30 21:36:18 +01:00 committed by GitHub
parent 8b2ce98578
commit e195c7cb43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -202,8 +202,17 @@ function aws_change_access_key() {
} }
function aws_regions() { function aws_regions() {
local region
if [[ $AWS_DEFAULT_REGION ]];then
region="$AWS_DEFAULT_REGION"
elif [[ $AWS_REGION ]];then
region="$AWS_REGION"
else
region="us-west-1"
fi
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}' aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
else else
echo "You must specify a AWS profile." echo "You must specify a AWS profile."
fi fi