AwsIP.info
 Hunter Fernandes
Software Engineer
Have you ever been in a position where someone gives you an AWS IP address, and you know nothing about it? What service uses it? What region is it for? Is it a typical region, a local zone, or a wavelength zone?
AWS publishes a list of IP ranges with all those details, but there isn’t an easy way to query it. It’s just a big JSON file.
To that end, I built awsip.info. Enter an AWS IP address and see what service it’s allocated to and where.
Deets
It’s a simple create-vite app in TypeScript. Did I really need React to render an IP address from a static list? No. But I was curious about UI and Vite and this is a personal project.
I did not want to have a backend database for a page that simply checks a static-ish list. However, I also wanted to minimize the data transfer to the client because downloading the whole 2 MB JSON file on every query sounds wasteful.
So I pre-process the file. On build, the script:
- Downloads the latest 
ip-ranges.json - Transforms each CIDR into its equivalent bitfield
 - Sorts the list of bitfields. This allows querying with binary search.
 - Compress the whole thing. Sorted lists compress well!
 - Base64 the binary because I need to get the value in a JavaScript file.
 
That takes the data size down to only 38 KB, even after inflating it with Base64! That is small enough that I can deploy my whole “application” to Cloudflare Workers. I don’t need a separate database (or to pull the file on the client) because I ship the compressed database as part of the code package that runs on Workers.
My / “page” maps to a Cloudflare Worker that checks the URL for an IP address query, looks it up in its internal data structure available in RAM, and then uses an HTMLRewriter to insert a data-results attribute onto the response page’s body element.
When the static page loads in the browser, it sees it has a data-results attribute and shows the result information from that.
Next Steps
While I like this approach (it works!), ultimately, I would like to cut out dynamism from the backend entirely. Ideally, the site should be entirely static.
I think I can do this by taking my sorted list of CIDRs, cutting them up into N equal-sized partitions, storing them in static storage, and storing the boundaries in JavaScript code that is ultimately shipped to the client.
Then, when the client performs a query, the client-side JavaScript locally knows which partition to search and fetch’s it.
But that’s for another day!