Service Discovery

Please read this article, on how Service Discovery can work for you.

aws_service_discovery_private_dns_namespace creates the private dns namespace and route53 zone needed needed for the ECS Services to register to.

resource "aws_service_discovery_private_dns_namespace" "namespace" {
  name        = "namespace.local"
  description = "Description"
  vpc         = "${module.vpc.vpc_id}"
}



The ECS Module has only implemented Service discovery for non-public namespaces. Only for AWSVPC networked ECS Services the dns_type A can be used, for bridge mode SRV.




WARNING

Apply Terraform first with the aws_service_discovery_private_dns_namespace resource before continuing.


module "demo_web" {
  ..
  service_discovery_enabled = true

  service_discovery_properties {
    namespace_id                         = "${aws_service_discovery_private_dns_namespace.namespace.id}"
    dns_ttl                              = "60"
    dns_type                             = "A"
    routing_policy                       = "MULTIVALUE"
    healthcheck_custom_failure_threshold = "1"
  }
  ..
}