Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cli.command('entrypoint', short_help="Use for a Docker entrypoint", context_settings=dict(ignore_unknown_options=True))
@click.pass_context
@click.argument('command', nargs=-1)
@click.option(
'--dry-run/--no-dry-run',
default=False,
help="Don't actually run the task, but print what we would have done"
)
def entrypoint(ctx, command, dry_run):
"""
Use this as the entrypoint for your containers.
It will look in the shell environment for the environment variables
DEPLOYFISH_SERVICE_NAME and DEPLOYFISH_CLUSTER_NAME. If found, it will
use them to:
\b
@cli.command('delete', short_help="Delete a service from AWS")
@click.pass_context
@click.argument('service_name')
@click.option('--dry-run/--no-dry-run', default=False, help="Don't actually delete the service")
@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()
@cli.command('exec', short_help="Connect to a running container")
@click.pass_context
@click.argument('service_name')
@click.option('--verbose/--no-verbose', '-v', default=False, help="Show all SSH output.")
@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)
@cli.command('version', short_help='Print image tag of live service')
@click.pass_context
@click.argument('service_name')
@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())
@cli.command('restart', short_help="Restart all tasks in service")
@click.pass_context
@click.argument('service_name')
@click.option('--hard/--no-hard', default=False, help="Kill off all tasks immediately instead of one by one")
@needs_config
def restart(ctx, service_name, hard):
"""
Restart all tasks in the service SERVICE_NAME by killing them off one by
one. Kill each task and wait for it to be replaced before killing the next
one off.
"""
service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
print()
click.secho('Restarting tasks in "{}" service in cluster "{}"'.format(
service.serviceName,
service.clusterName
))
@cli.command('scale', short_help="Adjust # tasks in a service")
@click.pass_context
@click.argument('service_name')
@click.argument('count', type=int)
@click.option('--dry-run/--no-dry-run', default=False, help="Don't actually scale the service")
@click.option('--wait/--no-wait', default=True, help="Don't exit until the service is stable with the new count")
@click.option('--asg/--no-asg', default=True, help="Scale your ASG also")
@click.option(
'--force-asg/--no-force-asg',
default=False,
help="Force your ASG to scale outside of its MinCount or MaxCount"
)
@needs_config
def scale(ctx, service_name, count, dry_run, wait, asg, force_asg):
"""
Set the desired count for service SERVICE_NAME to COUNT.
"""
@cli.command('run_task', short_help="Run a one-shot task for our service")
@click.pass_context
@click.argument('service_name')
@click.argument('command')
@needs_config
def run_task(ctx, service_name, command):
"""
Run the one-off task COMMAND on SERVICE_NAME.
"""
service = FriendlyServiceFactory.new(service_name, config=ctx.obj['CONFIG'])
response = service.run_task(command)
if response:
print(response)
@cli.command('tunnel', short_help="Tunnel through an ECS cluster machine to the remote host")
@click.pass_context
@click.argument('tunnel_name')
@needs_config
def tunnel(ctx, tunnel_name):
"""
Tunnel through an EC2 instance in the ECS cluster.
The parameters for this command should be found in a tunnels: top-level section in the yaml file, in the format:
\b
tunnels:
- name: my_tunnel
service: my_service
host: config.MY_TUNNEL_DESTINATION_HOST
port: 3306
local_port: 8888