Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_docs
file-type-icondocker-service-with-firelens
file-type-iconexamples
file-type-iconmodules
file-type-iconecs-cluster
file-type-iconecs-daemon-service
file-type-iconecs-deploy-check-binaries
file-type-iconecs-deploy
file-type-iconecs-fargate
file-type-iconecs-scripts
file-type-iconecs-service-with-alb
file-type-iconecs-service-with-discovery
file-type-iconecs-service
file-type-iconREADME-ECS-Fargate.adoc
file-type-iconREADME.adoc
file-type-iconauto_scaling.tf
file-type-iconcore-concepts.md
file-type-icondeployment_check.tf
file-type-iconelb.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconservice_discovery.tf
file-type-icontask_definition.tf
file-type-iconvariables.tf
file-type-iconecs-task-scheduler
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_docs
file-type-icondocker-service-with-firelens
file-type-iconexamples
file-type-iconmodules
file-type-iconecs-cluster
file-type-iconecs-daemon-service
file-type-iconecs-deploy-check-binaries
file-type-iconecs-deploy
file-type-iconecs-fargate
file-type-iconecs-scripts
file-type-iconecs-service-with-alb
file-type-iconecs-service-with-discovery
file-type-iconecs-service
file-type-iconREADME-ECS-Fargate.adoc
file-type-iconREADME.adoc
file-type-iconauto_scaling.tf
file-type-iconcore-concepts.md
file-type-icondeployment_check.tf
file-type-iconelb.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconservice_discovery.tf
file-type-icontask_definition.tf
file-type-iconvariables.tf
file-type-iconecs-task-scheduler
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...
ECS Service

ECS Service

Deploy an ECS service with zero-downtime, rolling deployment, IAM Role, auto scaling, and more.

Code Preview

Preview the Code

mobile file icon

README.adoc

down

maintained%20by gruntwork.io %235849a6 Terraform version

This module creates an Elastic Container Service (ECS) Service that you can use to run one or more related, long-running Docker containers, such as a web service. An ECS service can automatically deploy multiple instances of your Docker containers across an ECS cluster (see the ecs-cluster module), restart any failed Docker containers, route traffic across your containers using an optional Elastic Load Balancer (ELB), and optionally register the services to AWS Service Discovery Service. Additionally, CodeDeploy blue/green deployments are supported as the module can be enabled to ignore CodeDeploy managed resources.

ECS Service architecture

Features

  • Deploy and manage one or more docker containers as a logical unit

  • Deploy on Fargate or EC2 instances

  • Auto scaling and auto healing containers

  • Canary deployments

  • CodeDeploy blue/green deployment support (using external CICD)

  • Service discovery through AWS Service Discovery Service

  • ELB (CLB, ALB, and NLB) support

  • VPC support

  • Verified deployments using the ECS deployment checker binary

Learn

Note
This repo is a part of the Gruntwork Infrastructure as Code Library, a collection of reusable, battle-tested, production ready infrastructure code. If you’ve never used the Infrastructure as Code Library before, make sure to read How to use the Gruntwork Infrastructure as Code Library!

Core concepts

Repo organization

  • modules: the main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.

    • modules/ecs-cluster: use this module to provision an ECS cluster with ECS container instances.

    • modules/ecs-scripts: use the scripts in this module to configure private docker registries and register ECS container instances to ECS clusters.

    • modules/ecs-service: use this module to deploy one or more docker containers as a ECS service, with options to use ELBs (CLB, ALB, or NLB), Service Discovery, or Fargate.

    • modules/ecs-daemon-service: use this module to deploy one or more docker containers that run on a regular schedule.

    • modules/ecs-deploy: use the scripts in this module to run one or more docker containers as a one time task on an ECS cluster.

    • modules/ecs-deploy-check-binaries: use the python binary packages in this module to check ECS service deployments to ensure that they are active and healthy.

  • examples: This folder contains working examples of how to use the submodules.

  • test: Automated tests for the modules and examples.

Gruntwork analysis

  • EC2 vs Fargate launch types: A detailed comparison between the two available launch types for ECS, showing you the trade-offs between ECS container instances and Fargate.

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 folder: The examples folder contains sample code optimized for learning, experimenting, and testing (but not production usage).

Production deployment

If you want to deploy this repo in production, check out the following resources:

Production-ready sample code from the Reference Architecture:

Support

If you need help with this repo or anything else related to infrastructure or DevOps, Gruntwork offers Commercial Support via Slack, email, and phone/video. If you’re already a Gruntwork customer, hop on Slack and ask away! If not, subscribe now. If you’re not sure, feel free to email us at support@gruntwork.io.

Contributions

Contributions to this repo are very welcome and appreciated! If you find a bug or want to add a new feature or even contribute an entirely new module, we are very happy to accept pull requests, provide feedback, and run your changes through our automated test suite.

License

Please see LICENSE.txt for details on how the code in this repo is licensed.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?