Skip to content

Instantly share code, notes, and snippets.

@babo
Last active September 22, 2016 11:05
Show Gist options
  • Save babo/6a3855dbad1d98b045c310573cba2302 to your computer and use it in GitHub Desktop.
Save babo/6a3855dbad1d98b045c310573cba2302 to your computer and use it in GitHub Desktop.
On AWS the metadata service is rate limited. The code below overloads the system pretty fast, returning an HTTP 429 error code
#!/bin/sh
set -e
ZONE=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null)
failed() {
echo Failed after ${X}
exec curl http://169.254.169.254/latest/meta-data/placement/availability-zone
}
trap failed EXIT
for X in {1..5000}; do
curl http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null | grep ${ZONE} > /dev/null
done
echo Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment