Skip to content

Instantly share code, notes, and snippets.

@pgriess
Last active February 20, 2017 17:45
Show Gist options
  • Save pgriess/905309a5bdf1884c5ea660907b736759 to your computer and use it in GitHub Desktop.
Save pgriess/905309a5bdf1884c5ea660907b736759 to your computer and use it in GitHub Desktop.
Use aws4sign.py to list AWS Route53 zones
# AWS keys
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
# Inputs to the signature algorithm; must be immutable
#
# The $now parameter in particular is interesting. The AWS signature algorithm
# includes the current time, which we pass to aws4sign.py using the -t option.
now=$(date '+%s')
url=https://route53.amazonaws.com/2013-04-01/hostedzone
# Compute all headers
auth_header=$(python2.7 ./aws4sign.py -t $now -p authorization $url | cut -f2)
date_header=$(python2.7 ./aws4sign.py -t $now -p x-amz-date $url | cut -f2)
content_header=$(python2.7 ./aws4sign.py -t $now -p x-amz-content-sha256 $url | cut -f2)
curl -s \
-H "authorization: $auth_header" \
-H "x-amz-date: $date_header" \
-H "x-amz-content-sha256: $content_header" \
$url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment