Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AWS ECS with Boto3

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

like image 592
p.magalhaes Avatar asked Nov 13 '15 20:11

p.magalhaes


1 Answers

Just change:

waiter = client.get_waiter('tasks_running')

for

waiter = client.get_waiter('tasks_stopped')
like image 87
p.magalhaes Avatar answered Oct 14 '22 23:10

p.magalhaes