Search code examples
amazon-web-servicesterraformamazon-ecsaws-fargateservice-discovery

Service discovery using ECS Fargate


I have 2 services within ECS Fargate running.

I have set up service discovery with a private dns namespace as all my services are within a private subnet.

enter image description here

When I try and hit my config container from another I am getting the following error.

http://config.qcap-prod:50050/config: Get "http://config.qcap-prod:50050/config": dial tcp: lookup config.qcap-prod on 10.0.0.2:53: no such host

Below is my Terraform

resource "aws_service_discovery_service" "config" {
  name = "config"

  dns_config {
    namespace_id = aws_service_discovery_private_dns_namespace.qcap_prod_sd.id

    dns_records {
      ttl  = 10
      type = "A"
    }
  }

  health_check_custom_config {
    failure_threshold = 1
  }
}

Is there another step I need to do to allow me to hit my container from another within ECS using Fargate?

My terraform code for my namespace is:

resource "aws_service_discovery_private_dns_namespace" "qcap_prod_sd" {
  name        = "qcap.prod"
  description = "Qcap prod service discovery"
  vpc         = module.vpc.vpc_id
}

Solution

  • The fix for this was to add

    module "vpc" {
      enable_dns_support = true
      enable_dns_hostnames = true
    }
    

    In the module block within the vpc module to allow the DNS hostnames to be resolved within my VPC