我有下一个代码将快照策略附加到特定实例的现有磁盘:
data "alicloud_ecs_disks" "db_disks" {
instance_id = alicloud_instance.db.id
}
resource "alicloud_ecs_auto_snapshot_policy" "common" {
...
}
resource "alicloud_ecs_auto_snapshot_policy_attachment" "db" {
for_each = { for disk in data.alicloud_ecs_disks.db_disks.disks : disk.disk_id => disk }
auto_snapshot_policy_id = alicloud_ecs_auto_snapshot_policy.common.id
disk_id = each.key
}
当我运行计划时,它运行得很好,但在应用下一个计划后,由于错误而失败:
data.alicloud_ecs_disks.db_disks.disks is a list of object, known only after apply
â
â The "for_each" value depends on resource attributes that cannot be
â determined until apply, so Terraform cannot predict how many instances will
â be created. To work around this, use the -target argument to first apply
â only the resources that the for_each depends on.
解决这个问题的最佳选择是什么?它在某些机器上使用plan工作,有时不工作。谢谢