Skip to content

Commit 81503ce

Browse files
author
Jim Robinson
committed
Add command option
1 parent 4c04e7e commit 81503ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

croudtech_ecs_tools/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def cli():
125125

126126
@cli.command()
127127
@click.option("--region", required=True, default=os.getenv("AWS_DEFAULT_REGION", "eu-west-2"))
128-
def ecs_shell(region):
128+
@click.option("--command", default="bash")
129+
def ecs_shell(region, command):
129130
ecs_tools = EcsTools(region)
130131

131132
"Shell into an ECS task container"
@@ -142,7 +143,7 @@ def ecs_shell(region):
142143
container = ecs_tools.get_task_containers(cluster, task_arn)[int(click.prompt("Please select a container"))]["name"]
143144
click.secho("Connecting to Cluster:" + cluster + " Service:" + service_arn.split("/").pop() + " Task:" + task_arn.split("/").pop() + " Container: " + container, fg="green" )
144145
task_id = task_arn.split("/").pop()
145-
command = f"aws ecs execute-command --cluster {cluster} --task {task_id} --container {container} --interactive --command bash"
146+
command = f"aws ecs execute-command --cluster {cluster} --task {task_id} --container {container} --interactive --command {command}"
146147
click.secho("Executing command", fg="green")
147148
click.secho(command, fg="cyan")
148149
os.system(command)

0 commit comments

Comments
 (0)