I would like to lunch a Task on ECS cluster and wait for the task termination.
import boto3
client = boto3.client('ecs')
response = client.run_task(
cluster='default',
taskDefinition='RGB',
overrides={
'containerOverrides': [
{
'name': 'RGB',
'command': [
'python',
'-u',
'rgb.py'
]
}
]
}
)
arn = response["tasks"][0]['taskArn']
waiter = client.get_waiter('tasks_running')
waiter.wait(cluster='default', tasks=[arn])
Is it the correct way?
I am getting: botocore.exceptions.WaiterError: Waiter TasksRunning failed: Waiter encountered a terminal failure state
Just change:
waiter = client.get_waiter('tasks_running')
for
waiter = client.get_waiter('tasks_stopped')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With