Skip to content

Instantly share code, notes, and snippets.

@ragul28
Last active June 6, 2024 16:29
Show Gist options
  • Save ragul28/093810cc56d77d2a7c14f72b74d6c710 to your computer and use it in GitHub Desktop.
Save ragul28/093810cc56d77d2a7c14f72b74d6c710 to your computer and use it in GitHub Desktop.
Run aws command on all regions
function awsall {
export AWS_PAGER=""
for i in `aws ec2 describe-regions --query "Regions[].{Name:RegionName}" --output text|sort -r`
do
echo "------"
echo $i
echo "------"
echo -e "\n"
if [ `echo "$@"|grep -i '\-\-region'|wc -l` -eq 1 ]
then
echo "You cannot use – region flag while using awsall"
break
fi
aws $@ – region $i
sleep 2
done
trap "break" INT TERM
}
@russau
Copy link

russau commented Apr 3, 2024

I think you have a bug in the script where the instances of -- have been replaced with an EN DASH character. Putting back the double hyphens worked for me.

function awsall {
  export AWS_PAGER=""
  for i in `aws ec2 describe-regions --query "Regions[].{Name:RegionName}" --output text|sort -r`
  do
  echo "------"
  echo $i
  echo "------"
  echo -e "\n"
  if [ `echo "$@"|grep -i '\-\-region'|wc -l` -eq 1 ]
  then
      echo "You cannot use -- region flag while using awsall"
      break
  fi
  aws $@ --region $i
  sleep 2
  done
  trap "break" INT TERM
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment