gpt4 book ai didi

azure - Terraform 状态与外部更改同步

转载 作者:行者123 更新时间:2023-12-02 06:58:37 24 4
gpt4 key购买 nike

我在 Azure 中使用 terraform 管理我的基础设施。但是,在某些情况下,当其他服务也在更改基础设施时,状态可能会不同步。

例如,我让 terraform 创建一个应用程序网关。但我还有一个启用了 AGIC 的 AKS 集群,它可以动态更新/更改应用程序网关内部的规则、监听器等。因此,如果 terraform 在 AGIC 进行一些更改后重新运行,terraform 不知道并希望重置为它知道的默认配置。

也许这是不可能的,但是有没有一种自动方法来同步两者?每次都必须进入 terraform 配置并手动添加 AGIC 所做的更改,这是不可行的。此时,是否值得使用 terraform 管理应用程序网关?

最佳答案

如果您确实想使用 Terraform 创建应用程序网关,您可能应该使用生命周期元参数 ignore_changes关于将由 AKS 修改的属性。虽然并不完美,但至少他们可以分担责任,而不会互相覆盖。

The ignore_changes feature is intended to be used when a resource iscreated with references to data that may change in the future, butshould not affect said resource after its creation. In some rarecases, settings of a remote object are modified by processes outsideof Terraform, which Terraform would then attempt to "fix" on the nextrun. In order to make Terraform share management responsibilities of asingle object with a separate process, the ignore_changesmeta-argument specifies resource attributes that Terraform shouldignore when planning updates to the associated remote object.

例如:

resource "azurerm_application_gateway" "example" {
...

lifecycle {
ignore_changes = [
http_listener,
request_routing_rule,
backend_http_settings
]
}

...
}

关于azure - Terraform 状态与外部更改同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67426738/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com