Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run an AWS ECS task

I have an ECS fargate task defined in aws. I would like to run it occasionally as needed.

Is there an easy way to do this?

I have terraform code that defines it as a scheduled task that is disabled. Whenever I want to run it, my procedure is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  1. Modify the terraform file to enable the task and set the scheduled execution time for five minutes from now.
  2. Deploy the terraform and wait for the task to run.
  3. Undo the terraform changes and redeploy.

This procedure works, but is quite inconvenient. Surely there is a better way to run one-off tasks? I’ve tried going through the aws web console but it’s even worse.

>Solution :

If you want to stick with using the scheduler to run the task, then something like your current process is the only way to achieve that. However it sounds like you don’t really want to have the task run on a set schedule at all, instead you only want to run it when needed.

The most direct way to trigger an ECS task to run, is via the RunTask API, which you can trigger from the AWS CLI (which you could wrap in a shell script), or one of the AWS SDKs.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading