Ejemplo n.º 1
0
def update(task, image, tag, command, env, secret, role, region, access_key_id,
           secret_access_key, profile, diff, exclusive_env, exclusive_secrets,
           deregister):
    """
    Update a task definition.

    \b
    TASK is the name of your task definition family (e.g. 'my-task') within ECS.
    """
    try:
        client = get_client(access_key_id, secret_access_key, region, profile)
        action = UpdateAction(client)

        td = action.get_task_definition(task)
        click.secho('Update task definition based on: %s\n' %
                    td.family_revision)

        td.set_images(tag, **{key: value for (key, value) in image})
        td.set_commands(**{key: value for (key, value) in command})
        td.set_environment(env, exclusive_env)
        td.set_secrets(secret, exclusive_secrets)
        td.set_role_arn(role)

        if diff:
            print_diff(td)

        create_task_definition(action, td)

        if deregister:
            deregister_task_definition(action, td)

    except EcsError as e:
        click.secho('%s\n' % str(e), fg='red', err=True)
        exit(1)
Ejemplo n.º 2
0
def update(cluster, task, image, tag, command, env, role, tag_container,
           region, access_key_id, secret_access_key, profile, diff):
    """
    Update a task definition by creating a new revision.

    \b
    CLUSTER is the name of your cluster (e.g. 'my-cluster') within ECS.
    TASK is the name of your task definition (e.g. 'my-task') within ECS.
    """
    try:
        if tag_container and not tag:
            raise ValueError(
                "--tag must be specified if --tag-container is present")

        client = get_client(access_key_id, secret_access_key, region, profile)
        action = UpdateAction(client, cluster)

        td = action.get_task_definition(task)
        td.set_images(tag, tag_container,
                      **{key: value
                         for (key, value) in image})
        td.set_commands(**{key: value for (key, value) in command})
        td.set_environment(env)
        td.set_role_arn(role)

        if diff:
            print_diff(td)

        new_td = create_task_definition(action, td)

        click.secho('Updated task %s' % new_td.arn)

    except EcsError as e:
        click.secho('%s\n' % str(e), fg='red', err=True)
        exit(1)