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-icondocker-service-with-public-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-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-icondocker-service-with-public-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-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 public 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 using a public hostname. This allows querying the hostname trough the public internet. It is important to notice that the service is still private and the DNS query will return private IPs, only ECS Fargate supports auto assigning public IPs to your containers.

How do you run this example?

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

  1. Have a registered domain on Route 53
  2. Build the AMI
  3. (Optional) Create a VPC
  4. Apply the Terraform templates

Have a registered domain on Route 53

You can either register a new domain or transfer an existing domain to AWS using AWS Route 53, creating a public hosted zone for your domain.

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 and original_public_route53_zone_id with the hosted zone id of the public hostname you want to use as a namespace for your service.
  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?