ec2 实例和 AWS 自动缩放组

ec2 instances and AWS auto scaling group

我使用模块 https://github.com/terraform-aws-modules/terraform-aws-ec2-instance 在 AWS 上配置 ec2 实例。我想实现 AWS 自动缩放组功能,即如果其中一个 ec2 实例不健康,AWS 会自动替换它。但是,我没有在上面的 ec2 实例模块中看到代码、资源“aws_autoscaling_group”。 问题:

  1. 用ec2模块实现AWS Auto Scaling Group是否合理?我知道我们可以使用 eks 实施 AWS Auto Scaling Group。但是,我不确定 ec2 实例。
  2. 如果可以,怎么做?
  1. 是的,为 EC2 实例使用自动缩放组不仅合理,而且实际上被认为是最佳实践。

  2. 您可以使用 terraform 自动缩放模块:https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/latest