Hello, again! Dear community could you please help me to resolve the issue with kms aliases
.
Currently I’m able to create a kms keys
however when I’m trying to allocate the each created key id in kms aliases
it is giving me error, that string required, or if I use element
function I’m able to put only numeric index.
resource "aws_kms_alias" "global" {
for_each = { for keys in var.parameters : keys.name => keys if local.secrets.init.self == true }
depends_on = [ aws_kms_key.global ]
name = "alias/${lookup(each.value, "alias", "")}"
target_key_id = element([ for key, value in aws_kms_key.global : value.id ], 0)
}
The variable parameters
is list(map(string))
Actual problem is here >> target_key_id = element([ for key, value in aws_kms_key.global : value.id ], 0)
I need to somehow make something like target_key_id = element([ for key, value in aws_kms_key.global : value.id ], each.key/value)
Any idea how to manage this issue?