[英]How does terraform handle Infrastructure autoscaling
我知道 terraform 使用状态文件工作,但我想了解在放大/缩小实例的情况下我们如何处理 terraform。 示例:我有一个包含最少 1 个和最多 3 个实例的实例组。 在创建时我有一个实例,它扩展到 2 个实例。 现在,当我尝试运行“terraform apply”时,terraform 正在尝试将我的实例组缩减为 1。
我该如何解决这个问题?
在文档https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group他们 state:
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
以忽略更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.