Hey everyone! I’ve been trying to get a better handle on our AWS bill, and my team lead mentioned we should look into Reserved Instances to save money. The AWS Cost Explorer recommendations are helpful, but I wanted something I could automate a bit and play with the numbers offline.
I found a way to pull RI purchase recommendations using the AWS CLI and dump them into a spreadsheet. I'm still pretty new to CLI stuff, so I wanted to share what I did to see if it makes sense or if there's a better way. Basically, I used the `aws ce get-reservation-purchase-recommendation` command. I had to figure out the right JSON structure for the request, which was a bit tricky at first.
Here's the command I ended up with. I saved it as a script so I can run it weekly:
```bash
aws ce get-reservation-purchase-recommendations
--lookback-period-in-days SEVEN_DAYS
--term-in-years ONE_YEAR
--payment-option NO_UPFRONT
--service AmazonEC2
--recommendation-detail file://request.json
```
The `request.json` file lets me specify things like the account scope and which platform (like Linux/Unix). After running it, the output is a huge JSON blob. I used `jq` to filter it down to just the instance type, region, and estimated monthly savings, then exported that to a CSV file.
Once it's in a spreadsheet, I can sort by savings, add notes about which teams own which services, and even build a simple approval workflow. Has anyone else tried something like this? I'm curious if I'm missing any important columns that would help make a better purchase decision. Also, how do you usually track if the RIs you bought are actually being used? I've heard about RI utilization reports but haven't dug into those yet.
This process helped me understand the basics, but I’m sure there are more efficient ways to handle it. Appreciate any tips!