How to use the deployfish.config.needs_config function in deployfish

To help you get started, we’ve selected a few deployfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def docker_exec(ctx, service_name, verbose):
    """
    SSH to an EC2 instance in the cluster defined in the service named SERVICE_NAME, then
    run docker exec on the appropriate container.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    service.docker_exec(verbose=verbose)
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def task_write_config(ctx, task_name, dry_run):
    """
    If the task TASK_NAME has a "config:" section defined, write
    all of the parameters for the task to AWS Parameter Store.
    """
    task = Task(task_name, config=ctx.obj['CONFIG'])
    _write_config(task, task_name, dry_run)
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def task_run(ctx, task_name, wait):
    """
    Run the specified task, and if wait is true, wait for the task to finish and display
    any logs.
    """
    task = Task(task_name, config=ctx.obj['CONFIG'])
    try:
        task.run(wait)
    except:
        click.echo("There was an unspecified error running this task.")
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def cluster_info(ctx, service_name):
    """
    Show information about the individual EC2 systems in the ECS cluster running
    SERVICE_NAME.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    instances = service.get_instance_data()
    for index, reservation in enumerate(instances):
        click.echo(click.style("Instance {}".format(index + 1), bold=True))
        instance = reservation['Instances'][0]
        print("\tIP: {}".format(instance['PrivateIpAddress']))
        print("\tType: {}".format(instance['InstanceType']))
        for tag in instance['Tags']:
            print("\t{}: {}".format(tag['Key'], tag['Value']))
        print("")
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def scale(ctx, service_name, count, dry_run, wait, asg, force_asg):
    """
    Set the desired count for service SERVICE_NAME to COUNT.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    print()
    manage_asg_count(service, count, asg, force_asg)
    click.secho('Updating desiredCount on "{}" service in cluster "{}" to {}.'.format(
        service.serviceName,
        service.clusterName,
        count
    ), fg="white")
    if not dry_run:
        service.scale(count)
        if wait:
            click.secho("  Waiting until the service is stable with our new count ...", fg='cyan')
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def delete(ctx, service_name, dry_run):
    """
    Delete the service SERVICE_NAME from AWS.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    print()
    click.secho('Deleting service "{}":'.format(service.serviceName), fg="white")
    click.secho('  Service info:', fg="green")
    print_service_info(service)
    click.secho('  Task Definition info:', fg="green")
    print_task_definition(service.active_task_definition)
    print()
    if not dry_run:
        click.echo("If you really want to do this, answer \"{}\" to the question below.\n".format(service.serviceName))
        value = click.prompt("What service do you want to delete? ")
        if value == service.serviceName:
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def write_config(ctx, service_name, dry_run):
    """
    If the service SERVICE_NAME has a "config:" section defined, write
    all of the parameters for the service to AWS Parameter Store.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    parameters = service.get_config()
    if len(parameters) == 0:
        click.secho('No parameters found for service "{}":'.format(service_name), fg='white')
    else:
        if not dry_run:
            click.secho('Updating parameters for service "{}":'.format(service_name), fg='white')
        else:
            click.secho('Would update parameters for service "{}" like so:'.format(service_name), fg='white')
    print_sorted_parameters(parameters)
    if not dry_run:
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def version(ctx, service_name):
    """Print the tag of the image in the first container on the service"""
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    print(service.version())
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def show_config(ctx, service_name, diff, to_env_file):
    """
    If the service SERVICE_NAME has a "config:" section defined, print a list of
    all parameters for the service and the values they currently have in AWS.
    """
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    if not to_env_file:
        if diff:
            click.secho('Diff between local and AWS parameters for service "{}":'.format(service_name), fg='white')
        else:
            click.secho('Live values of parameters for service "{}":'.format(service_name), fg='white')
    parameters = service.get_config()
    if len(parameters) == 0:
        click.secho("  No parameters found.")
    else:
        if diff:
github caltechads / deployfish / deployfish / dplycli.py View on Github external
@needs_config
def cluster_run(ctx, service_name):
    """
    Run a command on each of the individual EC2 systems in the ECS cluster running
    SERVICE_NAME.
    """
    command = click.prompt('Command to run')
    service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
    responses = service.cluster_run([command])
    for index, response in enumerate(responses):
        click.echo(click.style("Instance {}".format(index + 1), bold=True))
        click.echo("Success: {}".format(response[0]))
        click.echo(response[1])