Load credentials into your shell via Bitwarden CLI - Fish edition

Recently I work with GitHub CLI a lot, and having to constantly fire up Bitwarden app to retrieve GITHUB_TOKEN gets old real fast… I was thinking of storing it in a gist in a password manager, luckily someone had the same idea and implemented it. The only issue is that I use fish shell. But we live in a world where there are many ways to interact with the shell, so it follows that you can translate zsh syntax to fish syntax. ...

November 29, 2022 · 1 min · Karn Wong

Cloudflare DNS management with Terraform

I self hosted a lot of services, sometimes I try out a few apps that would get deleted within the same day. All this requires setting up CNAME for reverse-proxy (because I want to make sure there’s no funny reverse-proxy shenanigans going on, for future reference). I can always log into Cloudflare console and manually add CNAME entries, but this is getting too tiresome since all I really need is another CNAME with the same config as the rest of the CNAMEs - pointing to the same DNS for my homelab. Cue lightbulb moment when I realize I can use Terraform to set it up. ...

November 20, 2022 · 1 min · Karn Wong

Deploy more efficiently with templating

You are building a website, it’s a simple frontend that needs to call the database for [total lead drops this week]. Your website is still at an infancy stage, with only a few features. At this point, you contemplate whether you need a proper backend or not. But to deploy a backend properly, it would involve docker, backend database, persistence storage, DNS, load balancer, among other things. But it looks like you don’t have enough time, so you decide to go with serverless, since it takes less time to implement and you don’t have to worry about scaling. ...

November 5, 2022 · 3 min · Karn Wong

IaC is cool, until someone specified the wrong machine size 💸

Back in the day, there was no cloud. If you want a lot of computing power, you need to build your own data center, and this is very expensive. Then cloud happened, and suddenly you can work with a lot of flexibility like you couldn’t before. Want to try out a small deployment? Sure! If your workload is heavier you can always increase the VM specs. It would almost be the end of the story, until someone realize “oh my God how did I set up VPC peering with another VPC, and which route table did I choose? I need to replicate it with another client and I forgot how”. THe issue isn’t that working with the cloud’s web ui doesn’t work, rather it doesn’t leave a trail for you, so over time the knowledge of how things were set up are lost, gone forever. I’m sure you can always mitigate this by documenting things, but then it can happen that someone modified the infrastructure without updating the documentation. Can’t blame them, it’s only normal when you have to synchronize things manually. ...

November 3, 2022 · 3 min · Karn Wong

Deploy static site with branch preview via Cloudflare Pages

Updated 2023-02-20: update terraform code For frontends, if no server-side rendering is required, we can deploy it as a static site. If you already use GitHub, you might be familiar with GitHub Pages. One common use case is to deploy your personal landing page / blog via GitHub Actions. Interestingly enough, this might cause problems if you are working in a team. For example, if you are working on a UI change, and you need to have someone else approve the changes, they would need to build the site locally to do so. ...

October 5, 2022 · 2 min · Karn Wong