2
votes

I use the module, https://github.com/terraform-aws-modules/terraform-aws-ec2-instance to provision the ec2 instances on AWS. I would like to have AWS auto scaling group feature implemented, i.e. in case one of the ec2 instances is not healthy, AWS auto replaces it. But, I do not see the code, resource "aws_autoscaling_group" inside the above ec2 instance module. Question:

  1. Is it reasonable to implement AWS auto scaling group with the ec2 module? I understand we can implement AWS auto scaling group with eks. But, I am not sure about ec2 instances.
  2. If it is possible, how to do it?
1

1 Answers

2
votes
  1. Yes, it is not only reasonable, but actually considered a best practice to use an auto scaling group for EC2 instances.

  2. you can do so using the terraform autoscaling module: https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/latest