Skip to main content

ECS Task Definition

๐Ÿ“ฆ Overviewโ€‹

This Terraform module provisions an Amazon ECS Task Definition with configurable container and runtime parameters. It acts as a reusable workload blueprint for ECS services or scheduled tasks.


โœ… Key Featuresโ€‹

  • Creates a reusable ECS task definition with specified family name
  • Supports custom container name, image, CPU, and memory
  • Compatible with both Fargate and EC2 launch types
  • Environment tagging for visibility and organization

๐Ÿ’ผ Use Casesโ€‹

  • Launch containers as part of ECS services or batch jobs
  • Maintain reusable deployment templates across environments
  • Support blue/green deployments and CI/CD pipelines
  • Isolate task configuration from runtime environment

๐Ÿ“ฅ Input Variablesโ€‹

NameTypeDescription
regionstringAWS region where the task definition is created
task_familystringFamily name for the ECS task definition
container_namestringName of the container
container_imagestringContainer image (e.g., nginx:latest)
cpunumberCPU units for the task
memorynumberMemory (in MiB) for the task
environmentstringTag representing the environment

๐Ÿ“ค Outputsโ€‹

NameDescription
task_definition_arnThe full ARN of the ECS task definition
task_familyThe logical family name assigned to the task

๐Ÿš€ Deployment Readinessโ€‹

  • โœ… Compatible with Terraform 1.0+
  • โœ… Uses AWS Provider 5.x+
  • ๐Ÿ” Requires ecs:RegisterTaskDefinition permissions

๐Ÿ› ๏ธ Example Usageโ€‹

module "ecs_task_definition_deployment" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//container/ecs-task-definition?ref=v1.0.0"

region = "us-east-1"
task_family = "archiphire-task"
container_name = "app"
container_image = "nginx:latest"
cpu = 256
memory = 512
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

๐Ÿงน Cleanupโ€‹

Terraform Destroy (Isolated Use):

terraform destroy

or

tofu destroy

Manual Deregistration (Recommended for Production):

aws ecs deregister-task-definition --task-definition archiphire-task:<revision>

๐Ÿ›ก๏ธ Notesโ€‹

This is a Level 1 container module intended for foundational ECS task configuration.
To run the task, use it in combination with ECS service, event bridge, or step function modules.
Supports modular scaling and environment-specific overrides.


๐Ÿ”’ Deployment Package Noticeโ€‹

This module is part of the Level 1 AWS License Tier.
To access the full deployment package and source code, subscribe to Archiphire.