in network-load-balancer-copy-utility/copy_network_load_balancer.py [0:0]
def register_backends(target_groups, nlb_data):
"""
Register back-ends to the NLB
Given target_groups and nlb_data
add the instances from nlb_data to the target_groups given
"""
if debug:
logger.debug("Registering targets with the Network Load Balancer")
if len(nlb_data['instanceIds']) >= 1:
for target_group in target_groups:
targets = []
for instance in nlb_data['instanceIds']:
target = {'Id': instance}
targets.append(target)
try:
response = client.register_targets(
TargetGroupArn=target_group['arn'], Targets=targets)
except botocore.exceptions.ParamValidationError as exception:
logger.error("Failed to register targets")
logger.error(exception)
sys.exit(1)
if debug:
logger.debug("Register targets response:")
logger.debug(response)