AWS boto3 billing information - python-3.x

I'm looking for a way to extract billing information using boto3. I've seen solutions using cost explorer but it's not a choice in my case. The information I want to extract is on Billing Dashboard > Bills. Is there a service on boto3 that facilitates this task?

I found a solution, using boto3. Using the CloudWatch client we can extract Billing metrics for any service we want:
Monitor Estimated Charges with CloudWatch
CloudWatch.Metric.get_statistics

Related

Azure Retail Prices overview

Reading the official documentation about Azure Retail Prices overview, I found that we can make API calls filtering by serviceName
https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices
https://prices.azure.com/api/retail/prices?$filter=serviceName eq
'Virtual Machines'
However, this assumes that we know the service's correct name.
How do we get a list of all service names in Azure?
In AWS there is an endpoint that returns a list of all AWS service names, and we can use that data in the subsequent API calls.
I found this article but it is not exactly what I would expect from Azure side.
https://dev.to/holger/how-to-retrieve-a-list-of-available-services-from-the-azure-retail-rates-prices-api-2nk6
Thank you!

Is it possible to access cross-account cloudwatch metrics programatically using CloudWatchClient

I've followed the Cross-Account Cross-Region Cloudwatch console tutorial and am able to see cloudwatch metrics from my other AWS account in the cloudwatch console.
Am I able to query these metrics using GetMetricStatisticsCommand when using credentials of my new AWS account? (i.e. the account that did not produce these metrics)
Any help would be massively appreciated as I can't see any documentation in the CloudwatchClient about achieving this.
Thanks!

Is there any way to get Savings info of spot instance by AWS CLI

I googled but can't find it. Can we obtain the spot usage and savings info in Savings tab on Spot instance by AWS CLI?
Yes and No.
General pricing information is available via Using the AWS Price List API - AWS Billing and Cost Management
Current spot prices are available via DescribeSpotPriceHistory - Amazon Elastic Compute Cloud
You would need to calculate the difference yourself.

How to calculator cost per month in AWS SDK?

I want to use nodejs to calculate the cost and billing each month for my users in AWS.
However, I could not find SDK support to get cost and billing information each month.
There are some node.js sdk available under Budgets section. See if you can use these api's to cater to your needs.
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Budgets.html
AWS supports programmatic access to billing data. Basically you assign an S3 bucket and then parse the CSV log files that billing generates.
Programmatic Access to AWS Billing Data
API Reference

Rackspace and Microsoft Azure pricing api

Is there a public api for getting pricing lists of Rackspace and Microsoft Azure in JSON format?
Have been searching for that but could not find any information.
Thank you in advance.
For Rackspace, there is not a public API for getting pricing lists in JSON format. You can find a list of the prices for Cloud Servers here if you scroll down to the "pricing" section: http://www.rackspace.com/cloud/servers
You can select a class of OS, service level, and whether you want the prices to be displayed hourly or monthly. Rackspace doesn't offer cloud servers without a support plan, so you'll need to factor that into your calculations. With the DevOps support plan, you'll need to factor in the volume discount for large numbers of servers.
There's also a price calculator here: http://www.rackspace.com/calculator
(Disclaimer: I work at Rackspace.)
For Azure, this may help.
I was looking for the same thing and stumble upon this post on stack overflow: Azure pricing calculator api. I was able to generate JSON string using this git hub repo: https://github.com/Azure-Samples/billing-dotnet-ratecard-api.
Hope this helps!

Resources