Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ECS Fargate Scheduled Task not running

I'm trying to setup a scheduled task with ECS Fargate but I cannot figure out why it is not running. I can confirm the task works correctly using RunTask but when I try to trigger it on a schedule all I get is a bunch of 'FailedInvocations' with no explanation.

I do know though that the rule is being triggered so this is a good sign. See the screenshot below:

enter image description here

But everytime it is triggered there is just a 'FailedInvocation'. Here's the scheduling rule:

enter image description here

And the default permissions on the ecsEventRole with just ecs:runTask:

enter image description here

{     "Version": "2012-10-17",     "Statement": [         {             "Effect": "Allow",             "Action": [                 "ecs:RunTask"             ],             "Resource": [                 "*"             ]         }     ] } 

My hunch says that this ecsEventsRole doesn't have enough permissions. Should I try to give it the ones that ecsTaskExecutionRole has?

Thanks

EDIT: This is now supported in us-east-1 region. See comments.

like image 662
coolboyjules Avatar asked Dec 25 '17 21:12

coolboyjules


People also ask

How do I run an ECS scheduled task manually?

Open the Amazon ECS console at https://console.aws.amazon.com/ecs/ . In the navigation pane, choose Task Definitions and select the task definition to run. To run the latest revision of a task definition, select the box to the left of the task definition to run.

How do I check my scheduled jobs on AWS?

To view your scheduled tasks (Amazon ECS console)Open the Amazon ECS console at https://console.aws.amazon.com/ecs/ . Choose the cluster your scheduled tasks are run in. On the Cluster: cluster-name page, choose the Scheduled Tasks tab. All of your scheduled tasks are listed.


2 Answers

Although it's been over an year, AWS still don't have a proper way to see invocation logs.

As you already know we can invoke tasks by RunTask manually, so does Scheduled Task.

The only difference is that Scheduled Task is triggered by CloudWatch rules.

We can easily see invoke logs in CloudTrail Event history, go there and filter events with Event name: RunTask and select the time range you want to check, find the event and click View Event, you'll see the error code and response.

like image 110
12 revs, 2 users 98% Avatar answered Sep 20 '22 22:09

12 revs, 2 users 98%


I ran into a similar issue where regular ECS Scheduled Tasks were not running.

I finally resolved it by adding an additional policy to ecsEventsRole which allows CloudWatch Events to pass IAM roles to ECS Tasks:

{     "Version": "2012-10-17",     "Statement": [         {             "Effect": "Allow",             "Action": [                 "iam:ListInstanceProfiles",                 "iam:ListRoles",                 "iam:PassRole"             ],             "Resource": "*"         }     ] } 
like image 38
Jason Avatar answered Sep 21 '22 22:09

Jason