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.
More on Loops, Conditionals, Dynamic Blocks and Functions
How does `count` work?BeginnerHow does `for_each` work?BeginnerWhen should you choose `for_each` over `count`?IntermediateHow do you use `for_each` with a list of objects?IntermediateWhat does "The for_each value depends on resource attributes that cannot be determined until apply" mean?AdvancedHow do you create a resource conditionally?Beginner