Skip to content

Instantly share code, notes, and snippets.

@mrchristine
Created December 11, 2019 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchristine/8568304a8b6a2db9e1ce57df7902dfbf to your computer and use it in GitHub Desktop.
Save mrchristine/8568304a8b6a2db9e1ce57df7902dfbf to your computer and use it in GitHub Desktop.
Calculate S3 costs for Storage
#!/bin/bash
# get the last date in the file
last_date=`cat $@ | awk -F',' '{print $5}' | awk '{print $1}' | grep -v "Start" | sort | uniq | tail -n1`
# pass in the report.csv and calculate total storage costs for StandardStorage tier
cat "$@" | grep $last_date | awk -F, '{printf "%.2f GB %s %s \n", $7/(1024**3 )/24, $4, $2}' | grep "StandardStorage" | uniq | sort -n
echo "Processed for $last_date"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment