Skip to content

Instantly share code, notes, and snippets.

@rsalmond
Created December 2, 2016 23:36
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 rsalmond/25f987ff9f82852ad06e63e978ce6f4c to your computer and use it in GitHub Desktop.
Save rsalmond/25f987ff9f82852ad06e63e978ce6f4c to your computer and use it in GitHub Desktop.
import boto.ec2
from pprint import pprint
# https://aws.amazon.com/ebs/previous-generation/
# https://aws.amazon.com/ebs/details/
sizes = {
u'standard' : {
'count': 0,
'rate': 0.05
},
u'gp2' : {
'count': 0,
'rate': 0.10
},
u'io1' : {
'count': 0,
'rate': 0.125
},
u'st1' : {
'count': 0,
'rate': 0.045
},
u'sc1' : {
'count': 0,
'rate': 0.025
}
}
if __name__ == '__main__':
ec2 = boto.ec2.connect_to_region('us-east-1')
for volume in ec2.get_all_volumes():
if volume.status != u'in-use':
sizes[volume.type]['count'] += volume.size
total = 0
for voltype in sizes:
cost = sizes[voltype]['rate'] * sizes[voltype]['count']
total += cost
print 'type: {voltype}, monthly: ${cost}'.format(voltype=voltype, cost=cost)
print 'total: {}'.format(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment