Interview Prep/Terraform/Loops, Conditionals, Dynamic Blocks and Functions

Why can `timestamp()` cause trouble?

IntermediateConceptLoops, Conditionals, Dynamic Blocks and Functions
Answer

It returns the current time on every evaluation, so putting it into a resource attribute creates a diff on every plan. For tags we avoid it or use lifecycle { ignore_changes = [tags["created"]] }. Terraform 1.5 added plantimestamp(), which returns the time of the plan and is meant for checks and validations rather than resource arguments. uuid() has the same problem.

All Terraform questions Roadmap: Terraform

More on Loops, Conditionals, Dynamic Blocks and Functions