Is it possible (with terraform 0.12) to have a dynamic ignore_changes in a lifecycle block?
What I’m hoping to achieve is to make ignoring changes to “user_data” optional in one of our modules.
Yes that works but my goal was to make ignoring user_data optional. For most use cases of our module we don’t want to ignore user_data changes but for some we do.
That doesn’t seem possible: “The lifecycle settings all effect how Terraform constructs and traverses the dependency graph. As a result, only literal values can be used because the processing happens too early for arbitrary expression evaluation.”
They might not close&reject such a feature request right away, but I think it’s unlikely that it would be resolved quickly.
Closest I can think of, right now, is to have duplicate resource declarations in the module, and use one for the case where you ignore changes to userdata and the other where you don’t. But if you change your mind, it’s destroy and recreate.