Use when it fits · AWS · Long-running jobs

Fargate scheduled tasks

Containers that run only while the job runs. The answer for a two-hour nightly job.

I used to break every long job into small Lambda steps because I thought Fargate meant paying around the clock. It doesn't. An EventBridge Scheduler rule starts an ECS task on Fargate, the container runs for as long as the job takes, and you pay per second for that run only.

Use it when

  • A job runs longer than Lambda's 15 minutes (nightly imports, reports, migrations, batch AI).
  • A job needs more memory, disk or tooling than a Lambda comfortably has.

Don't use it when

  • The job can be broken into small steps that each finish well inside 15 minutes. Lambda is simpler.
  • The service must answer HTTP 24/7. That's a different (always-on) Fargate design.

Pricing

Per second of vCPU and memory while the task runs (one-minute minimum). Nothing between runs. Fargate Spot is cheaper if the job can be interrupted.

In my words: what hurts

  • I assumed Fargate meant paying 24/7. A scheduled task doesn't.

Gotchas, with fixes

Gotcha: Fargate Spot tasks can be stopped with two minutes' notice.

Fix: Use Spot only for jobs that checkpoint or can safely restart.

Provisioning

Official Pulumi package · Official Terraform provider

ECS task definition + EventBridge Scheduler schedule, all in @pulumi/aws.

Instead, consider

Where it fits

Sources

Last reviewed by Nicolas Dao

Want this stack in your AWS account?

Cloudless Labs is a Sydney consultancy. We migrate on-premises systems to AWS, build serverless apps on this stack, and coach teams to ship with Claude Code and Codex.

Contact Us

For general inquiries, please contact us at:

For e-learning capabilities, please contact: