Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-ecs-fargate-service

Deploy containerized applications on AWS ECS Fargate — no servers to manage. Includes auto-scaling, deployment circuit breaker, CloudWatch logging, and secrets support.

Features

  • Serverless containers — No EC2 instances to manage
  • Auto-scaling — CPU-based target tracking
  • Circuit breaker — Auto-rollback on failed deployments
  • Secrets — AWS Secrets Manager / SSM Parameter Store integration
  • Logging — CloudWatch Logs with configurable retention
  • ALB ready — Optional load balancer integration
  • Container Insights — ECS monitoring enabled by default

Usage

Basic (public-facing service)

module "api" {
  source = "github.com/akshayghalme/terraform-ecs-fargate-service"

  cluster_name    = "my-cluster"
  service_name    = "api"
  vpc_id          = module.vpc.vpc_id
  subnet_ids      = module.vpc.private_subnet_ids
  container_image = "123456789.dkr.ecr.us-east-1.amazonaws.com/api:latest"
  container_port  = 8080
  cpu             = 512
  memory          = 1024
  desired_count   = 2

  environment_variables = {
    NODE_ENV = "production"
    PORT     = "8080"
  }

  enable_autoscaling = true
  min_count          = 2
  max_count          = 10

  tags = { Environment = "production" }
}

Fargate Pricing Guide

CPU Memory Monthly (1 task, 24/7)
256 (.25 vCPU) 512 MB ~$9.40
512 (.5 vCPU) 1 GB ~$18.80
1024 (1 vCPU) 2 GB ~$37.60
2048 (2 vCPU) 4 GB ~$75.20

License

MIT

Author

Akshay Ghalmeakshayghalme.com

About

Deploy containerized apps on AWS ECS Fargate. Auto-scaling, deployment circuit breaker, secrets management, and CloudWatch logging.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages