Amazon ECS Fargate Cluster
Overview
This service contains Terraform code to deploy a production-grade ECS cluster for Fargate usage only on AWS using Elastic Container Service (ECS).
This service launches an ECS cluster on top of Fargate that is completely managed by AWS. If you wish to launch an ECS cluster on top of an Auto Scaling Group, refer to the ecs-cluster module. Refer to the section EC2 vs Fargate Launch Types for more information on the differences between the two flavors.
ECS architecture
Features
This Terraform Module launches an EC2 Container Service Cluster that you can use to run Docker containers on Fargate and Fargate Spot.
Learn
This repo is a part of the Gruntwork Service Catalog, a collection of reusable, battle-tested, production ready infrastructure code. If you’ve never used the Service Catalog before, make sure to read How to use the Gruntwork Service Catalog!
Under the hood, this is all implemented using Terraform modules from the Gruntwork terraform-aws-ecs repo. If you are a subscriber and don’t have access to this repo, email support@gruntwork.io.
Core concepts
To understand core concepts like what is ECS, and the different cluster types, see the documentation in the terraform-aws-ecs repo.
Repo organization
- modules: the main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.
- examples: This folder contains working examples of how to use the submodules.
- test: Automated tests for the modules and examples.
Deploy
Non-production deployment (quick start for learning)
If you just want to try this repo out for experimenting and learning, check out the following resources:
- examples/for-learning-and-testing folder: The
examples/for-learning-and-testing
folder contains standalone sample code optimized for learning, experimenting, and testing (but not direct production usage).
Production deployment
If you want to deploy this repo in production, check out the following resources:
- examples/for-production folder: The
examples/for-production
folder contains sample code optimized for direct usage in production. This is code from the Gruntwork Reference Architecture, and it shows you how we build an end-to-end, integrated tech stack on top of the Gruntwork Service Catalog.
Manage
For information on how to manage your ECS cluster, see the documentation in the terraform-aws-ecs repo.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S ECS-FARGATE-CLUSTER MODULE
# ------------------------------------------------------------------------------------------------------
module "ecs_fargate_cluster" {
source = "git::git@github.com:gruntwork-io/terraform-aws-service-catalog.git//modules/services/ecs-fargate-cluster?ref=v0.118.1"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The name of the ECS cluster
cluster_name = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# A map of custom tags to apply to the ECS Cluster. The key is the tag name
# and the value is the tag value.
custom_tags = {}
# Whether or not to enable container insights monitoring on the ECS cluster.
enable_container_insights = true
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S ECS-FARGATE-CLUSTER MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-service-catalog.git//modules/services/ecs-fargate-cluster?ref=v0.118.1"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The name of the ECS cluster
cluster_name = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# A map of custom tags to apply to the ECS Cluster. The key is the tag name
# and the value is the tag value.
custom_tags = {}
# Whether or not to enable container insights monitoring on the ECS cluster.
enable_container_insights = true
}
Reference
- Inputs
- Outputs
Required
cluster_name
stringThe name of the ECS cluster
Optional
custom_tags
map(string)A map of custom tags to apply to the ECS Cluster. The key is the tag name and the value is the tag value.
{}
Whether or not to enable container insights monitoring on the ECS cluster.
true