Registering Targets
Learn to register targets with the load balancer.
We'll cover the following...
The next step is to register targets with the target group. This assigns targets (WordPress instances in our case) to the target group so the load balancer can later address them all together.
The elbv2 register-targets command needs the following parameters:
--target-group-arnto specify the target group.--targetsto specify the targets (our WordPress instances). To specify instances, we can use theId=<instance id>syntax. Other options instead ofIdareipfor an IP address,lambdafor an AWS Lambda function (we will not cover those), andalbfor another load balancer (an Application Load Balancer to be precise).
We can list multiple targets separated by a space, so it looks like this:
To get the <target-group-arn> directly from our target group via its name, we can use elbv2 describe-target-groups with the --names parameter and filter the output. This is very similar to the other describe commands we have used already.
It looks like this:
We can then insert this into the elbv2 register-targets command to pass the --target-group-arn parameter to get the following: