Hi,
I'm trying to use the recently added Hourly billing queries but I can't get it to work with boto3. I have had success using the very latest awscli (1.16.292), but version 1.10.28 of boto3 at least does not appear to work for me.
The query I'm using:
import boto3
from datetime import datetime, timedelta
CURRENT_HOUR = datetime.today().replace(minute=0,second=0,microsecond=0)
PREVIOUS_HOUR = CURRENT_HOUR - timedelta(hours=1)
aws_client = boto3.client(
'ce',
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
)
response = aws_client.get_cost_and_usage(
TimePeriod={
'Start': PREVIOUS_HOUR.isoformat() + 'Z',
'End': CURRENT_HOUR.isoformat() + 'Z',
},
Granularity='HOURLY',
Metrics=['UNBLENDED_COST'],
GroupBy=[
{
'Type': 'DIMENSION',
'Key': 'SERVICE'
},
{
'Type': 'DIMENSION',
'Key': 'LINKED_ACCOUNT'
}
]
)
Can anyone replicate this?
Edited by: ElliottIwoca on Nov 29, 2019 3:44 AM
Edited by: ElliottIwoca on Nov 29, 2019 3:48 AM
Edited by: ElliottIwoca on Nov 29, 2019 3:48 AM