Whitelisting with Xonsh

Updated: Mar 25

The Problem

I rent a little house on a huge ranch a touch over an hour northwest of Austin, TX. I also work as a software engineer for Quansight primarily utilizing Python. The beauty of this setup is the hybrid techy/rural lifestyle I enjoy. And the baby bison. The downside, the internet.

Small group of bison with a baby bison

(photo from my kitchen window)

My only source of internet is via a cell phone hotspot. Luckily, modern cell phone plans offer just enough data to make this possible-so long as you’re willing to sacrifice Netflix binges. One side effect of using a cell phone hotspot is a constantly changing public IP address. For most folks, this isn’t a problem. When working on Amazon EC2 instances that utilize IP address whitelists to secure SSH traffic, it’s a pain. Each day (and randomly throughout) my IP address will change. Every time it changed I would perform this ritual:

  1. Login to AWS console

  2. Open EC2

  3. Open the corresponding security group

  4. Lookup my IP on Google

  5. Add the new IP

This got old fast.


After living with this extremely manual process for several months, I was in a meeting with a DevOps engineer who said: “Whenever I have to do something twice, I automate it.” This was the motivation I needed to rid myself of a repetitive task. The first tool that came to mind was AWS CLI. I was very familiar with this command line tool after using it on several different projects. I considered a Bash script, but quickly remembered how little fun I had last time I created a Bash script. There had to be a better way without having to deal with a new language for a single task.