essh - Ephemeral SSH keys for EC2 hosts using EC2 instance connect

At work, we recently standardised on Amazon Linux 2 for several reasons. One of which was to take advantage of EC2 instance connect so we no-longer have a public key distribution problem, and can grant SSH access using IAM. I initially wrote a quick shell script to create and use…

Quickly access Terraform docs from the CLI or Vim

As I've mentioned before, I use Terraform every day at work, and am constantly looking up the documentation for the many resources. I've had a simple shell script called tfdoc to speed up looking at docs for a while, found here: https://github.com/z0mbix/sysadmin-tools/blob/master/tfdoc Whilst…

ctag support for Terraform

Anyone working in the land of systems and infrastructure automation these days will no doubt have heard of Terraform. At work, we use it for pretty much everything, and being a long time vim user and fan, I wanted to work a little bit smarter as I spend a lot…

Find EC2 region an instance resides in

Quite often you'll find yourself needing to know the region your instance resides in. I've seen this done a couple of ways: $ curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/\([1-9]\).$/\1/g' This is pretty ugly, so I prefer to use this method…

Sniffing Elasticsearch Queries

Recently at work we were trying to find out exactly what query was running that was causing an exception in our application. Fortunately, this was quick and easy using good old tcpdump: # tcpdump -A -nn -s 0 \ "tcp dst port 9200 and \ (((ip[2:2] - ((ip[0]&0xf)…