def tag_instances_on_cluster(cluster_name, project='cwc'):
    'Adds project tag to untagged instances in a given cluster.\n\n    Parameters\n    ----------\n    cluster_name : str\n        The name of the AWS ECS cluster in which running instances\n        should be tagged.\n    project : str\n        The name of the project to tag instances with.\n    '
    ecs = boto3.client('ecs')
    task_arns = ecs.list_tasks(cluster=cluster_name)['taskArns']
    if (not task_arns):
        return
    tasks = ecs.describe_tasks(cluster=cluster_name, tasks=task_arns)['tasks']
    container_instances = ecs.describe_container_instances(cluster=cluster_name, containerInstances=[task['containerInstanceArn'] for task in tasks])['containerInstances']
    ec2_instance_ids = [ci['ec2InstanceId'] for ci in container_instances]
    for instance_id in ec2_instance_ids:
        tag_instance(instance_id, project=project)
    return
Adds project tag to untagged instances in a given cluster.

Parameters
----------
cluster_name : str
    The name of the AWS ECS cluster in which running instances
    should be tagged.
project : str
    The name of the project to tag instances with.
def tag_instances_on_cluster(cluster_name, project='cwc'):
    'Adds project tag to untagged instances in a given cluster.\n\n    Parameters\n    ----------\n    cluster_name : str\n        The name of the AWS ECS cluster in which running instances\n        should be tagged.\n    project : str\n        The name of the project to tag instances with.\n    '
    ecs = boto3.client('ecs')
    task_arns = ecs.list_tasks(cluster=cluster_name)['taskArns']
    if (not task_arns):
        return
    tasks = ecs.describe_tasks(cluster=cluster_name, tasks=task_arns)['tasks']
    container_instances = ecs.describe_container_instances(cluster=cluster_name, containerInstances=[task['containerInstanceArn'] for task in tasks])['containerInstances']
    ec2_instance_ids = [ci['ec2InstanceId'] for ci in container_instances]
    for instance_id in ec2_instance_ids:
        tag_instance(instance_id, project=project)
    return