Terraform 忽略动态块的变化

问题描述 投票:0回答:0

我有 aws_alb_listener 的动态操作,但是 terraform 生命周期忽略更改给出了这个错误。我想在进行 terraform apply 时忽略重量变化。我试过 [0]、* 和其他一切

Block type "target_group" is represented by a set of objects, and set elements
do not have addressable keys. To find elements matching specific criteria, use
a "for" expression with an "if" clause.

resource "aws_alb_listener" "app" {
  load_balancer_arn  = aws_alb.app.arn
  
  default_action {
    type = "forward"
    forward {
      target_group {
        arn    = aws_lb_target_group.P[name].arn
        weight = 100
      }
      dynamic "target_group" {
        content {
          <boolean condition>
          arn    = aws_lb_target_group.A[name].arn
          weight = 0
        }
      }
      dynamic "target_group" {
        content {
          <boolean condition>
          arn    = aws_lb_target_group.B[name].arn
          weight = 0
        }
      }
      dynamic "target_group" {
        <boolean condition>
        content {
          arn    = aws_lb_target_group.C[name].arn
          weight = 0
        }
      }
    }
  }

  lifecycle {
    create_before_destroy = true
    # GIVES ERROR
    ignore_changes        = [default_action[0].forward[0].target_group[0].weight]
  }
}
terraform lifecycle
© www.soinside.com 2019 - 2024. All rights reserved.