AWS ALB Target group and instance association/dissociation.

Hi,
I am trying to understand the best way to remove and add an instance to a target group. Basically, what I want to do is

  1. Query an ALB to get the list of the target groups by supplying the name of the ALB ( in a variable ).
  2. Filter the list to get the target group that we need ( using a regular expression as the target group name can change from time to time ) from the list returned by the above query…
  3. Remove an instance one at a time from the target group.
  4. Apply updates on the instance.
  5. Add the instance back to the target group.
  6. Repeat 3-5.

Thanks.

Why?

Is this target group maintained by a scaling group, or are they all “pets”? A “pet” being an instance that is in some way uniquely configured.

The usual way to get things updated is to make a new AMI incorporating your changes, test the new AMI in a dev environment, then if all is well update the launch configuration to use the new AMI and start killing the running instances; they will be replaced by instances based on your new, improved AMI.

If you do have “pets”, go look at AWS System manager: https://aws.amazon.com/systems-manager/

Regards, K.

Thanks for the reply. Basically, I am trying to do a deployment like what we usually do in the instances connected to an ELB. I do not need to update the AMI for the deployment.
Basically, if there are 2 instances behind the target group, I would take one of them out first, do the deployment and put it back to the target group. I would repeat the same for the other instance too.