Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active December 3, 2018 08:46
Show Gist options
  • Save yuvalif/d2a57bee9a0046999f56dd3d540d9252 to your computer and use it in GitHub Desktop.
Save yuvalif/d2a57bee9a0046999f56dd3d540d9252 to your computer and use it in GitHub Desktop.
Get the list of objects in an s3 bucket via curl
#!/bin/bash
set -ex
resource=$1
host=localhost
port=$2
dateValue=`date -Ru`
S3KEY=$SYSTEM_ACCESS_KEY
S3SECRET=$SYSTEM_SECRET_KEY
stringToSign="GET\n\n\n${dateValue}\n${resource}"
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${S3SECRET} -binary | base64`
curl -X GET \
-H "Authorization: AWS ${S3KEY}:${signature}" \
-H "Date: ${dateValue}" \
-H "Host: ${host}:${port}" \
http://${host}:${port}${resource} --verbose
echo -e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment