Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import datetime
- import boto3
- now = datetime.datetime.now()
- START = "{}-{}-01".format(now.year, now.month)
- END = "{}-{}-{}".format(now.year, now.month, now.day)
- client = boto3.client('ce', 'us-east-1')
- a = client.get_cost_and_usage(
- TimePeriod={"Start": START, "End": END},
- Granularity="MONTHLY",
- Metrics=["UnblendedCost"],
- )
- print("Total spend from {} to {} is {} USD".format(
- START, END, a['ResultsByTime'][0]['Total']['UnblendedCost']['Amount']))
Add Comment
Please, Sign In to add comment