def create_tg()

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


def create_tg(**tg_args):
    """
    Creates target group.

    Accepts:
    - tg_args: tg_args is dictionary with required key:value
    pair. You can add values to dictionary as required. Dictionary should
    strictly follow the naming convention as below:
        tg_args = {
            'name': 'tg1',
            'protocol': 'GENEVE',
            'port': 6081,
            'healthchkproto': 'HTTP',
            'healthchkport': '80',
            'healthchkpath': '/',
            'vpc_id': 'vpc-xxxx',
            'type': 'instance'
        }

    Usage:
    - create_tg(**tg_args)
    """
    logging.info(f"Creating target group: {tg_args['name']}")
    try:
        response = elbv2.create_target_group(
            Name=tg_args['name'],
            Protocol=tg_args['protocol'],
            Port=tg_args['port'],
            HealthCheckProtocol=tg_args['healthchkproto'],
            HealthCheckPort=tg_args['healthchkport'],
            HealthCheckPath=tg_args['healthchkpath'],
            VpcId=tg_args['vpc_id'],
            TargetType=tg_args['type']
        )
        tg_arn = response['TargetGroups'][0]['TargetGroupArn']
        return response, tg_arn
    except ClientError as e:
        logging.error(e)
        return None