【问题标题】:Can you make an attribute not trigger resource change?您可以使属性不触发资源更改吗?
【发布时间】:2020-05-10 01:18:42
【问题描述】:

在 Terraform 中,有没有办法设置一个属性,使其不会触发资源更新?

例子:

resource "google_cloudfunctions_function" "sometimes_changes" {
  ...

  # label the function with timestamp - don't let this trigger an update.

  labels = {
    timestamp = timestamp
  }
}

【问题讨论】:

    标签: terraform terraform-provider-gcp


    【解决方案1】:

    试试ignore_changes block:

    resource "google_cloudfunctions_function" "sometimes_changes" {
    
    ...
        lifecycle {
            ignore_changes = [
              labels,
            ]
        }
    }
    

    【讨论】:

    • 啊哈。这很接近,但不完全是我想要的。 ignore_changes 导致该字段被完全忽略以用于资源更新。期望的行为是在没有更新其他属性时忽略该属性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2021-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    相关资源
    最近更新 更多