SHARE
TWEET

Untitled

a guest Jun 25th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from datetime import datetime, timedelta
  2. import boto3
  3.  
  4. today = datetime.today()
  5. yesterday = today - timedelta(days=1)
  6. seconds_in_1day = 86400
  7. dimensions = [{"Name": "Currency", "Value": "USD"}]
  8.  
  9. client = boto3.client('cloudwatch', region_name='us-east-1')
  10. res = client.get_metric_statistics(
  11.     Namespace='AWS/Billing',
  12.     MetricName='EstimatedCharges',
  13.     StartTime=yesterday,
  14.     EndTime=today,
  15.     Period=seconds_in_1day,
  16.     Statistics=["Average"],
  17.     Dimensions=dimensions)
  18. print('$%s' % res['Datapoints'][0]['Average'])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top