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โ
| Name | Type | Description |
|---|---|---|
| region | string | AWS region where the task definition is created |
| task_family | string | Family name for the ECS task definition |
| container_name | string | Name of the container |
| container_image | string | Container image (e.g., nginx:latest) |
| cpu | number | CPU units for the task |
| memory | number | Memory (in MiB) for the task |
| environment | string | Tag representing the environment |
๐ค Outputsโ
| Name | Description |
|---|---|
| task_definition_arn | The full ARN of the ECS task definition |
| task_family | The logical family name assigned to the task |
๐ Deployment Readinessโ
- โ Compatible with Terraform 1.0+
- โ Uses AWS Provider 5.x+
- ๐ Requires
ecs:RegisterTaskDefinitionpermissions
๐ ๏ธ 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.