def cluster_ssh(ctx, service_name):
"""
SSH to the specified EC2 system in the ECS cluster running SERVICE_NAME.
"""
service = Service(
yml=Config(filename=ctx.obj['CONFIG_FILE'], env_file=ctx.obj['ENV_FILE']).get_service(service_name))
ips = service.get_host_ips()
for index, ip in enumerate(ips):
click.echo("Instance {}: {}".format(index+1, ip))
instance = click.prompt("Which instance to ssh to?", type=int)
if instance > len(ips):
click.echo("That is not a valid instance.")
return
instance_ip = ips[instance-1]
service.cluster_ssh(instance_ip)
评论列表
文章目录