I would like to import existing SSM parameters without overwrite value_wo but after import there is detected change for value_wo_version so value_wo is updated
my current setup
locals {
workspace = "development"
instance = "a"
instance_name = "test-${local.instance}"
api = {
static = {
ABC_1 = "abc_1"
}
dynamic = {
DEF_1 = {import = true}
}
}
api_envs = merge(local.api.static, local.api.dynamic)
}
import {
for_each = {
for key, value in local.api.dynamic : key => value
if lookup(value, "import", false)
}
to = aws_ssm_parameter.api_env[each.key]
identity = {
name = format("/%s/api/%s", local.instance_name, lower(each.key))
has_value_wo = true
value_wo_version = "20260127"
}
}
resource "aws_ssm_parameter" "api_env" {
for_each = local.api_envs
name = format("/%s/api/%s", local.instance_name, lower(each.key))
type = "SecureString"
value = can(tostring(each.value)) ? tostring(each.value) : null
value_wo = can(tostring(each.value)) ? null : lookup(each.value, "default", "tbd")
value_wo_version = can(tostring(each.value)) ? null : "20260127"
tags = {
managed_by = "terraform"
environment = local.workspace
instance = local.instance
type = can(keys(each.value)) ? "dynamic" : "static"
}
lifecycle {
ignore_changes = [value_wo]
}
}
Any ideas how should I do that?