• Matt's Memos
  • Posts
  • What a monkey patching library tells you about Azure

What a monkey patching library tells you about Azure

Spoiler: it’s not good.

Hey folks,

The mapotf terraform wrapper tool makes me cringe on two levels:

  1. Monkey patching, dynamic modification of code at runtime to work around a bug or feature limitation, is a code smell. It makes it hard to reason about the code and logic. I learned that as a junior engineer in my first professional code base. I get it. When you need to monkey patch, you really need to—there’s a bug that is impacting your system and you can’t wait for an upstream fix. But it should be rare. Needing to modify code behavior at runtime often enough to require a library to assist indicates unfixed features and bugs are terrifyingly commonplace. Oof.

  2. This tool is built and maintained by the Azure team and not some random open source contributor. My understanding is that with Azure, you often to need to use lifecycle.ignore_change to tell TF to ignore and not manage certain attributes. This often required because of the mess that is their system/API/resource model changing resource attributes in the background continuously. What that says to me is that the Azure team is actively building hacky terraform wrappers to accomplish monkey patching at scale so they can get around their own shortcomings as a Cloud API. Double oof.

What do you think? Am I missing something?

May you never need to monkey patch,

PS I enjoyed discussing the infrastructure as code landscape on Ned In The Cloud YouTube channel a few months ago. We covered the current landscape of IaC, the latest trends, and the challenges companies face when adopting IaC strategies. Check it out here.