Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect EC2 instance to Target Group using Ansible

Tags:

ansible

I have been working for a while registering EC2 instances to ELB's using Ansible. But now I'm starting to use ALB's and I need to connect my instances to Target Groups which in turn are connected to the ALB. Is there an Ansible plugin that allows me to register an instance to a AWS Target Group?

like image 769
de.la.ru Avatar asked Oct 11 '16 11:10

de.la.ru


1 Answers

Since Ansible does not support registration of instances to target groups I had to use the AWS-CLI tool. With the following command you can register an instance to a target group:

aws elbv2 register-targets --target-group-arn arn:aws:elasticloadbalancing:us-east-1:your-target-group --targets Id=i-your-instance

So I just call this command from Ansible and it's done.

like image 112
de.la.ru Avatar answered Oct 14 '22 21:10

de.la.ru