Good day, Recent AWS release API for know the billing information.
It is available in all aws SDK (c#,python,php). I just tried a lambda function to update my database table with current cost of my all linked accounts. but mt lambda function doesn't work. it show the following error
"Unknown service: 'ce'. Valid service names are: acm, apigateway, application-autoscaling, appstream, athena, autoscaling,etc "
my lambda code is :
import boto3
from datetime import datetime, timedelta
def lambda_handler(event, context):
client1 = boto3.client(
'ce',
aws_access_key_id=accesskey,
aws_secret_access_key=secretkey)
[referral link for client creation][1]
response = client1.get_cost_and_usage(
TimePeriod={
'Start': startdate,
'End': enddate
},
Granularity='MONTHLY',
Metrics=[
'BlendedCost',
],
GroupBy=[
{
'Type': 'DIMENSION',
'Key': 'LINKED_ACCOUNT'
},
],
)
print response