0

I have an ECS cluster, an active service for it, and a task for this service. I am trying to call ListTasks with Ruby AWS SDK.

When there is no active task, it comes through with an empty list, as expected. But when there is a running task, I get the Aws::ECS::Errors::ClusterNotFoundException.

I tried calling ListClusters, and got a successful response: {:cluster_arns=>["arn:aws:ecs:<region>:<account_num>:cluster/<cluster_name>"], :next_token=>nil}.

I also tried calling DescribeServices, and got a successful response as well: {:clusters=>[{:cluster_arn=>"arn:aws:ecs:<region>:<account_num>:cluster/<cluster_name>", :cluster_name=>"<cluster_name>", :status=>"ACTIVE", :registered_container_instances_count=>0, :running_tasks_count=>1, :pending_tasks_count=>0, :active_services_count=>1, :statistics=>[], :tags=>[], :settings=>[{:name=>"containerInsights", :value=>"enabled"}], :capacity_providers=>["FARGATE_SPOT", "FARGATE"], :default_capacity_provider_strategy=>[{:capacity_provider=>"FARGATE", :weight=>1, :base=>0}], :attachments=>nil, :attachments_status=>nil}], :failures=>[]}.

In addition, I regularly call DescribeServices and UpdateService for the same cluster name successfully.

But the error persists for ListTasks.

Has anyone encountered something similar? What do you think is happening?

UPD The code that generates the error:

@@ecs_client = Aws::ECS::Client.new(
  region: Aws.config[:region],
  access_key_id: Aws.config[:credentials].access_key_id,
  secret_access_key: Aws.config[:credentials].secret_access_key
)

...

tasks = @@ecs_client.list_tasks({ cluster: '<cluster_name>' })
Olesya
  • 272
  • 1
  • 3
  • 8

1 Answers1

0

If you do not specify a cluster when calling the "ListTasks" API, the "default" cluster is assumed. Also, double check the region used in your script.

once
  • 1,369
  • 4
  • 22
  • 32
  • My code `tasks = @@ecs_client.list_tasks({ cluster: '' })`, took it from the docs. The region I get through `Aws.config[:region]`, and it's the same everywhere, also the cluster is in the same region as everything else. – Olesya Jun 15 '21 at 09:18