how to implement "sticky" variables in terraform?
16:17 18 Oct 2019

I'd like to have a Terraform variable with these properties:

  • if it has never been set, use a default value
  • if no value is provided, use the value from the previous run
  • if a value is provided, use that and remember it

The use case is for AWS ECS tags, where I want to be able to deploy a new version by changing the tag, which will cause Terraform to create a new task definition and modify the service definition. If I run "terraform apply", though, without passing a new value I'd like nothing to happen, i.e., terraform remembers the value from the previous run.

Suggestions welcome!

terraform amazon-ecs