Let’s say you have following SSM parameter resource
resource aws_ssm_parameter private_key {
name = var.name
type = "SecureString"
value = var.key
overwrite = true
tags = var.tags
}
The value of var.key variable changes every time terraform runs. But you need to be able to prevent value update based on some conditions (say, bool variable var.overwrite_old_value).
You can’t use overwrite = property, because if it’s set to false terraform will throw an exception attempting to overwrite the value.
You can’t use lifecycle { ignore_chanes = [...] } because it requires static attribute values and doesn’t accept variables, functions etc.
So how do you update the value only the condition is met? Continue reading →
