Terraform for Expressions (Maps)

Terraform map for expressions decide more than formatting. They define identity.

A list changes order. A map changes meaning.

When you build a map with a for expression, you are assigning keys that Terraform uses as resource addresses. That key becomes part of state. That means a simple rename is not a rename. It is a destroy and recreate event.

This lesson breaks down how map for expressions work, how filtering affects key presence, and how transformed maps feed directly into for_each. The goal is not syntax. The goal is control over infrastructure lifecycle.

If you treat keys like labels, you will eventually break something.