我知道 terraform 使用 statefile 工作,但我想了解我们如何在放大/缩小实例的情况下处理 terraform。 例子: 我有一个实例组,最少有 1 个实例,最多有 3 个实例。在创建时我有一个实例,它扩展到 2 个实例。现在,当我尝试运行“terraform apply”时,terraform 正在尝试将我的实例组缩小到 1。
我该如何解决这个问题?
答案 0 :(得分:-1)
在文档中as described here他们声明:
the aws_autoscaling_group resource must be configured to ignore changes to the load_balancers and target_group_arns arguments within a lifecycle configuration block.
使用 ignore_changes
忽略自动缩放更改,示例:
resource "aws_autoscaling_group" "example" {
# ...
lifecycle {
ignore_changes = [
load_balancers,
target_group_arns
]
}
}
测试,如果没有按预期工作,添加 min
和 max
以忽略更改