Uncategorized
erik
Once upon a time

Terraform Lessons Learned

Cloud Posse is a prolific producer of Open Source terraform modules. A fun fact is that every module we have is the result of some customer contribution that sponsored the development of the module. That has resulted in a snowball effect so that now we have hundreds of modules and countless battle scars.

To get where we are today, we made a lot of mistakes.

  • We had Inconsistent Resource Names. Used lots of string concatenation to build resource names, but there was poor consistency, and frequently a module couldn't be instantiated more than once in an account.

  • We had a lot of redundant modules.
  • We did do too much in a module, had too many variable inputs, too many permutations
  • We relied extensively on environment variables. Hey! It's 12-factor, right?
  • We version pinned specific modules in every stage.
  • We used precise version pinning in all of our open-source modules.
  • We bought into the "terraform workspaces are evil" mantra and reinvented the concept of workspaces without using workspaces (because that is what everyone does who has multiple environments and doesn't use workspaces)

Here are some things we've learned along the way to watch out for.

Stop...

  • Configuration combined with your modules
  • Using folder structures to connote your state. Refactoring changes your state. Do Yudel folder structures to connote the states of your applications? Probably not. The. Why for your infra?

  • Running it by hand
  • Using terraform workspaces
  • You are generating vast amounts of your terraform code
  • You have are mixing lifecycles of resources that are totally disjoint creating a terrralyth

Do any of these mistakes sound familiar?

Share This Post: