2

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?
Melissa Jenner
  • 781
  • 1
  • 8
  • 31

1 Answers1

2
  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

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108
  • There is no output of private IP of EC2 instances. It looks like I can only use user data to install stuffs I need at EC2 instance provision time. I cannot use the ASG ec2 instances as my application server since I deploy new releases from time to time. It means I have to logon to the instance via IP, user data does not work. – Melissa Jenner Nov 24 '20 at 01:31