• Uncategorized

About linux : aws-ce-cli-get-service-wise-cost-for-last-7Days

Question Detail

As a part of the daily job, I have to open the AWS cost explorer and extract the last 7 days of service-wise costing.

I want to automate the whole process and the output format should be a CSV as below

Service,EC2-Instances($),EC2-Other($),Relational Database Service($),S3($)

I have found one command which gives me the total costing of the last 7 days but can’t figure out how to get this type of result insted.

The current command I am using:

aws ce get-cost-and-usage \
 --time-period Start=$(date +"%Y-%m-%d" --date="-240 hours"),End=$(date +"%Y-%m-%d") \
 --granularity=DAILY \
 --metrics BlendedCost \
 --query "ResultsByTime[].[TimePeriod.Start, Total.BlendedCost.[Amount][0], Total.BlendedCost.[Unit][0]]" \
 --output text

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.