AWS Boto3 provides multiple service access like for Cost Explorer
AWS Cost Explorer has an easy-to-use interface that lets you visualize, understand, and manage your AWS costs and usage over time. But with AWS Boto3 SDK, we will be using Python Client
to connect to our AWS account services.
A low-level client representing AWS Cost Explorer Service
You can use the Cost Explorer API to programmatically query your cost and usage data. You can query for aggregated data such as total monthly costs or total daily usage. You can also query for Granular-Data
. This might include the number of daily write operations for Amazon DynamoDB database tables in your production environment.
import boto3
client = boto3.client('ce')
The service endpoint for cost explorer is
There are multiple methods which can be used by our client to fetch data from the cost explorer as per our reuqirements in JSON
format.
The granularities supported by the AWS Cost Explorer are :
HOURLY | DAILY | MONTHLY
The method used here to fetch the data from the cost explorer is get_cost_and_usage.
All the required paramenters are passed into the method and upon successful completion of the code, we will get the response.
- awscli
- Configure AWS credentials for target account
- run
aws configure
- run
- Cost Explorer Enabled
- Verfied Amazon SES Sender email
- To send to other addresses, you need to move SES out of sandbox mode.