from awacs.aws import Statement, Principal, Allow, Policy
from awacs import sts


def make_simple_assume_statement(principal):
    return Statement(
        Principal=Principal('Service', [principal]),
        Effect=Allow,
        Action=[sts.AssumeRole])


def get_codedeploy_assumerole_policy():
    """ Helper function for building the AWS CodeDeploy AssumeRole Policy
    """

    service = 'codedeploy.amazonaws.com'
    policy = Policy(
        Statement=[make_simple_assume_statement(service)]
    )
    return policy


def get_default_assumerole_policy(region=''):
    """ Helper function for building the Default AssumeRole Policy

    Taken from here:
        https://github.com/boto/boto/blob/develop/boto/iam/connection.py#L29
    Used to allow ec2 instances to assume the roles in their InstanceProfile.
    """

    service = 'ec2.amazonaws.com'
    if region == 'cn-north-1':
        service = 'ec2.amazonaws.com.cn'
    policy = Policy(
        Statement=[make_simple_assume_statement(service)]
    )
    return policy


def get_ecs_assumerole_policy(region=''):
    """ Helper function for building the ECS AssumeRole Policy
    """

    service = 'ecs.amazonaws.com'
    policy = Policy(
        Statement=[make_simple_assume_statement(service)]
    )
    return policy


def get_lambda_assumerole_policy(region=''):
    """ Helper function for building the AWS Lambda AssumeRole Policy
    """

    service = 'lambda.amazonaws.com'
    policy = Policy(
        Statement=[make_simple_assume_statement(service)]
    )
    return policy

@@ -1276,32 +1276,306 @@
 return policy%0A%0A%0A
+def get_ecs_task_assumerole_policy(region=''):%0A    %22%22%22 Helper function for building the AssumeRole Policy for ECS Tasks%0A    %22%22%22%0A%0A    service = 'ecs-tasks.amazonaws.com'%0A    policy = Policy(%0A        Statement=%5Bmake_simple_assume_statement(service)%5D%0A    )%0A    return policy%0A%0A%0A
 def get_lambda_a

Add helper for get_ecs_task_assumerole_policy (#76)