def register_targets()

in python/gwlb/create_gwlb_tg_listener_sample.py [0:0]


def register_targets(tg_arn, target_string):
    """
    Registers targets with a target group:

    Accepts:
    - target_string: The ID of the target. If the target type of the target
    group is instance , specify an instance ID.
    - tg_arn: Target group ARN. Not required if retrieving from DynamoDB

    Usage:
    - register_targets(tg_arn='arn:aws:elasticloadbalancing:xxxxx', 'i-xxxx')
    """
    logging.info(f"Registering targets with target group: {tg_arn}")
    # waiter = elb.get_waiter('target_in_service')
    try:
        response = elbv2.register_targets(
            TargetGroupArn=tg_arn,
            Targets=[
                {
                    'Id': target_string
                },
            ]
        )
        return response
    except ClientError as e:
        logging.error(e)
        return None