I have made module that create aws ebs snapshot using volume_id.
In order to solve the dependency problem, the changed volume_id was ignored using lifecycle ignore_changes.
However, if you delete the volume_id from the list, the snapshot is also deleted.
Why is this happening?
please let me know.
locals {
ami_list = {
add_ebs = {
"helloec2" = {
volume_id = ["vol-05d530cd333625598",""]
}
}
}
}
module "add_snapshot" {
source = "./module/AMI/Add_ebs"
for_each = local.ami_list.add_ebs
name = each.key
volume_ids = each.value.volume_id
}
# module add_snapshot
resource "aws_ebs_snapshot" "data_ebs_snapshot" {
for_each = toset(var.volume_ids)
volume_id = each.key
tags = {
Name = "snapshot-data-${each.key}"
}
lifecycle {
ignore_changes = [
volume_id
]
}
}