Goal: Use the aws cli in a subprocess.run
call to execute a command in a container of a running task.
Example Usage: aws ecs execute-command --command "python -m task.function {arg}" --interactive --task {task_arn} --container Container
Encountered Error: /bin/sh: 1: Syntax error: "(" unexpected
Attempted Solutions:
json.dumps(arg)
:aws ecs execute-command --command "python -m task.function {"something": "that contains ( )"}" --interactive --task {task_arn} --container Name
json.dumps(arg).encode('utf-8')
:aws ecs execute-command --command "python -m task.function b'{"something": "that contains ( )"}'" --interactive --task {task_arn} --container Name
Why am I trying to use the cli through a subprocess.run
call?
- It doesn’t appear that there is an easy way to read the websocket : https://github.com/boto/boto3/issues/3496
- As indicated this SO answer only returns a very small portion of the websocket message: How can I get output from boto3 ecs execute_command?