Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-icondeploy-ecs-task
file-type-icondocker-daemon-service
file-type-icondocker-fargate-service-with-alb
file-type-icondocker-fargate-service-with-efs-volume
file-type-icondocker-fargate-service-with-nlb
file-type-icondocker-fargate-service-without-lb
file-type-icondocker-fargate-spot-service-with-alb
file-type-icondocker-service-with-alb-and-nlb
file-type-icondocker-service-with-alb-autoscaling
file-type-icondocker-service-with-alb-canary
file-type-icondocker-service-with-alb
file-type-icondocker-service-with-autoscaling
file-type-icondocker-service-with-canary-deployment
file-type-icondocker-service-with-elb
file-type-icondocker-service-with-private-discovery
file-type-iconcontainers
file-type-iconuser-data
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-icondocker-service-with-public-discovery
file-type-icondocker-service-without-elb
file-type-icondocker-vpc-service-with-alb
file-type-iconexample-docker-image
file-type-iconexample-ecs-instance-ami
file-type-iconexample-vpc
file-type-iconmodules
file-type-icontest
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_docs
file-type-iconexamples
file-type-icondeploy-ecs-task
file-type-icondocker-daemon-service
file-type-icondocker-fargate-service-with-alb
file-type-icondocker-fargate-service-with-efs-volume
file-type-icondocker-fargate-service-with-nlb
file-type-icondocker-fargate-service-without-lb
file-type-icondocker-fargate-spot-service-with-alb
file-type-icondocker-service-with-alb-and-nlb
file-type-icondocker-service-with-alb-autoscaling
file-type-icondocker-service-with-alb-canary
file-type-icondocker-service-with-alb
file-type-icondocker-service-with-autoscaling
file-type-icondocker-service-with-canary-deployment
file-type-icondocker-service-with-elb
file-type-icondocker-service-with-private-discovery
file-type-iconcontainers
file-type-iconuser-data
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-icondocker-service-with-public-discovery
file-type-icondocker-service-without-elb
file-type-icondocker-vpc-service-with-alb
file-type-iconexample-docker-image
file-type-iconexample-ecs-instance-ami
file-type-iconexample-vpc
file-type-iconmodules
file-type-icontest
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-...
EC2 Container Service (ECS) Cluster

EC2 Container Service (ECS) Cluster

Deploy a cluster of servers for use with EC2 Container Service (ECS), Amazon's container orchestration system

Code Preview

Preview the Code

mobile file icon

README.md

down

Docker Service with Service Discovery using a private DNS hostname

This example demonstrates how to set up an ECS cluster and then deploy an ECS service which can register itself with AWS Service Discovery. This allows reaching your service through a hostname that can be queried within your VPC.

How do you run this example?

To run this example, you need to do the following:

  1. Build the AMI
  2. (Optional) Create a VPC
  3. Apply the Terraform templates

Build the AMI

See the example-ecs-instance-ami docs.

Create a VPC

This example requires a VPC with private and public subnets. You can use the example-vpc example to create one if you do not already have one handy.

Apply the Terraform templates

To apply the Terraform templates:

  1. Install Terraform.
  2. Open vars.tf, set the environment variables specified at the top of the file, and fill in any other variables that don't have a default. This includes setting the ecs_cluster_instance_ami with the ID of the AMI you just built.
  3. Run terraform init.
  4. Run terraform apply, it will give you a plan and request if you wish to proceed.

Resources

  1. AWS ECS Service Discovery guide
  2. ecs-service-with-discovery module

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?