1

I am struggling to understand how to obtain pricing info. programmatically (that is, via URL or aws CLI). I suspect I am missing the 'big picture'.

I can estimate pricing manually on the web by, for example, aws marketplace -> operating systems -> select an AMI -> instance type. This gives an estimate cost.

I would like to do the same via the aws CLI or URL.

I want to compare costs for a variety of regions & instance types but this is too time consuming to explore manually.

To be specific, given an instance obtained using aws ec2 describe-images --owners aws-marketplace, how do I go about mapping this to the data in an offer file obtained using, for example, wget https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json?

Any suggestions appreciated (or redirect to more appropriate site).

1 Answer 1

2

There is an aws cli pricing command which returns a ton of information. I didn't find it to be very helpful by itself but if you ran it through jq it could give you what you're looking for. Here's the link to the docs. https://docs.aws.amazon.com/cli/latest/reference/pricing/index.html

I do not see a way to get information from the describe-images api that will allow you to price ec2 instances out. The results from the call do not contain an Instance Type.

I also found a similar question on Stack Overflow with some great references to the API calls you mentioned but it doesn't discuss the cli. https://stackoverflow.com/questions/7334035/get-ec2-pricing-programmatically

2
  • Thanks Ken; I had tried the aws pricing command with various subcommands such as get-products, describe-services, get-attribute-values, but could not find a way to do via CLI what I can easily do manually via the web :-(.
    – copper.hat
    Aug 23, 2018 at 2:11
  • Also, nice find. I thought I had looked at every related question :-).
    – copper.hat
    Aug 23, 2018 at 2:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .