Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach existing EC2 instances to auto scaling group in terraform?

I created 2 EC2 instances using terraform. Is there any way to attach them into auto scaling group using terraform? I didn't find anything about this in the docs :/

I don't want to create them within the ASG, only attached them. As I said the instances were generated by terraform script as well as everything else (ASG, SG...).

Thank you

like image 339
Galdil Avatar asked Mar 03 '23 10:03

Galdil


1 Answers

Unfortunately this is not possible via Terraform directly

However you could run the attach-instances AWS cli command.

If this needed to be performed in terraform you could put the command into a local-exec resource.

like image 59
Chris Williams Avatar answered Apr 08 '23 16:04

Chris Williams