Prerequisites
- Terraform >= 1.5.7 installed (install guide)
- AWS credentials configured in your environment (
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY, or an IAM role via instance profile / SSO) - Existing VPC and subnets — you need subnet IDs to place your ECS tasks
Steps
1
Configure the AWS provider
Create a
versions.tf file to pin the provider versions required by the module:2
Deploy an ECS cluster with a Fargate service
Create a
main.tf with the integrated root module. This configuration creates a cluster with Fargate on-demand and Fargate Spot capacity providers, and deploys a service with two containers: a FluentBit sidecar for log forwarding and the application container.Replace
subnet_ids, target_group_arn, and referenced_security_group_id with real values from your AWS account before applying.3
Apply and verify
Initialize and apply the configuration:After the apply completes, verify the cluster and service are running in the AWS console under ECS > Clusters, or use the AWS CLI:
What was created
After a successful apply, you have:Next steps
Fargate guide
Learn how to configure Fargate on-demand and Fargate Spot with mixed capacity provider strategies.
EC2 Auto Scaling
Attach an EC2 Auto Scaling Group as a capacity provider for full compute control.
Logging
Configure CloudWatch logging, FireLens, and FluentBit sidecars for your containers.
Autoscaling
Set up target tracking and scheduled scaling policies for your ECS services.

