Skip to content
A Terraform template used for provisioning scheduled tasks on AWS ECS Fargate
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
base adds encryption and lifecycle policy to remote state bucket (#5) Feb 20, 2019
env adds cluster tagging (#4) Jan 28, 2019
.gitignore initial (#1) Nov 5, 2018
diagram.png initial (#1) Nov 5, 2018

Terraform ECS Fargate Scheduled Task

A set of Terraform templates used for provisioning scheduled tasks on AWS ECS Fargate.

ECS Scheduled Tasks use CloudWatch Event Rules to run Fargate containers.


The templates are designed to be customized. The optional components can be removed by simply deleting the .tf file.

The templates are used for managing infrastructure concerns and, as such, the templates deploy a hello-world docker image. We recommend using the fargate CLI for managing application concerns like deploying your actual application images and environment variables on top of this infrastructure. The fargate CLI can be used to deploy applications from your laptop or in CI/CD pipelines.



These components are shared by all environments.

Name Description Optional AWS provider, output S3 bucket backend for storing Terraform remote state ECR repository for application (all environments share)


These components are for a specific environment. There should be a corresponding directory for each environment that is needed.

Name Description Optional Terrform remote state, AWS provider, output ECS Cluster, Service, Task Definition, ecsTaskExecutionRole, CloudWatch Log Group NSG for Task Application Role for container Yes IAM user that can be used by CI/CD systems Yes Ship container logs to Yes Add a base secret to Secretsmanager Yes


Typically, the base Terraform will only need to be run once, and then should only need changes very infrequently. After the base is built, each environment can be built.

# Move into the base directory
$ cd base

# Sets up Terraform to run
$ terraform init

# Executes the Terraform run
$ terraform apply

# Now, move into the dev environment
$ cd ../env/dev

# Sets up Terraform to run
$ terraform init

# Executes the Terraform run
$ terraform apply


Alternatively you can use the fargate-create CLI to scaffold new projects based on this template.


curl -s | sh

create an input vars file (terraform.tfvars)

# app/env to scaffold
app = "my-app"
environment = "dev"
schedule_expression = "rate(5 minutes)"

region = "us-east-1"
aws_profile = "default"
saml_role = "admin"
vpc = "vpc-123"
private_subnets = "subnet-123,subnet-456"
public_subnets = "subnet-789,subnet-012"
tags = {
  application   = "my-app"
  environment   = "dev"
  team          = "my-team"
  customer      = "my-customer"
  contact-email = ""
$ fargate-create -t

Additional Information

You can’t perform that action at this time.