I have tagged unversioned data stored in AWS S3 in the following form:
<bucket>/foo/
item-1
item-2
item-3 (inserted, read, then deleted)
/bar/
item-4
item-5
There is one bucket, several prefixes like foo and bar, and many items using those prefixes. Items are inserted, read, updated, and deleted daily. I would like to get a cost breakdown in S3, using prefixes, for example
+--------------+---------+---------------+
| Date | Cost, $ | AWS S3 Prefix |
+--------------+---------+---------------+
| 25-Jan-2024 | 11 | <bucket>/foo/*|
| 25-Jan-2024 | 15 | <bucket>/bar/*|
+--------------+---------+---------------+
I've looked at using Cost Allocation tags but that seems to be limited to a bucket level. I cannot get the cost breakdown based on differently-tagged resources inside the bucket. The CUR reports also don't group S3 resources using prefixes. Both cost allocation tags and CUR allow me to get this data:
+--------------+---------+---------------+
| Date | Cost, $ | AWS S3 Prefix |
+--------------+---------+---------------+
| 25-Jan-2024 | 11 | <bucket> |
+--------------+---------+---------------+
How do I programmatically get the costs of resources in AWS S3 grouped by a prefix?