try" sleep_sec = i * 10 ecs.update_container_instances_state( cluster: cluster, container_instances: arns, status: 'DRAINING') ecs.update_service(cluster: cluster, service: svc, desired_count: 1) updated_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) sleep sleep_sec ecs.update_container_instances_state( cluster: cluster, container_instances: arns, status: 'ACTIVE') ecs.wait_until(:services_stable, { cluster: cluster, services: [svc] }, delay: 1, max_attempts: nil) elapsed_sec = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - updated_time).round puts "Sleep: #{sleep_sec} sec, Elapsed: #{elapsed_sec} sec" # (snip)