Reputation: 21
I am looking to use containers to run a task every hour using containers. Imagine the task takes 20 minutes, so it's not suitable for lambda, and it's not suitable for EC2, since 40 minutes out of every hour the instance would be idle.
I have created a container that runs one simple task, (writes a row into a database) then stops. I created a docker container, pushed this to ECR, then created an ECS task that appears to run the task constantly (starting / restarting). I set the number of tasks to 0 for the cluster to stop this behaviour.
I then created a schedule using AWS event bridge, and set it to run the task every hour, but it's not running at all.
Can anyone suggest something that I should look at to achieve the desired scheduled task?
Upvotes: 1
Views: 864
Reputation: 201088
I created a docker container, pushed this to ECR, then created an ECS task that appears to run the task constantly (starting / restarting). I set the number of tasks to 0 for the cluster to stop this behaviour.
You actually created an ECS service which is designed to run a task 24/7, for things like web servers that need to be up all the time. You do not need an ECS service for your particular use case.
I then created a schedule using AWS event bridge, and set it to run the task every hour, but it's not running at all.
This is most likely a permissions issue, related to the IAM role you have given the . You can look in CloudTrail to see the ECS RunTask event that was invoked by EventBridge, and what the error was. You probably didn't give EventBridge the iam:PassRole
permission, or the ecs:RunTask
permission.
Upvotes: 2