Hi All,
I was hoping to get some input into the following as I cant seem to get it working:
I have some Service Discovery set up using the following code:
data "aws_vpc" "default" {
tags = {
app = "cfola"
}
}
resource "aws_service_discovery_private_dns_namespace" "cfola" {
name = "cfola.local"
vpc = data.aws_vpc.default.id
}
resource "aws_service_discovery_private_dns_namespace" "mockserver" {
name = "mockserver.local"
vpc = data.aws_vpc.default.id
}
resource "aws_service_discovery_service" "cfola" {
name = "cfola"
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.cfola.id
dns_records {
ttl = 10
type = "A"
}
routing_policy = "MULTIVALUE"
}
health_check_custom_config {
failure_threshold = 1
}
}
resource "aws_service_discovery_service" "mockserver" {
name = "mockserver"
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.mockserver.id
dns_records {
ttl = 10
type = "A"
}
routing_policy = "MULTIVALUE"
}
health_check_custom_config {
failure_threshold = 1
}
}
And then I have 2 services set up as follows:
resource "aws_ecs_service" "cfola_svc" {
name = "${var.stage}-cfola-${var.suffix}"
cluster = var.config.cluster.name
task_definition = aws_ecs_task_definition.cfola.arn
desired_count = 2
launch_type = "FARGATE"
depends_on = [
aws_lb_target_group.cfola,
aws_lb_listener.cfola_svc,
]
load_balancer {
target_group_arn = aws_lb_target_group.cfola.arn
container_name = "${var.stage}-cfola"
container_port = 3000
}
network_configuration {
security_groups = [var.config.secgrps.svc.id]
subnets = data.aws_subnet_ids.private_subnet_ids.ids
assign_public_ip = true
}
service_registries {
registry_arn = aws_service_discovery_service.cfola.arn
}
}
resource "aws_ecs_service" "cfola_mockserver" {
name = "${var.stage}-cfola-mockserver"
count = var.stage == "dev" ? 1 : 0
cluster = var.config.cluster.name
task_definition = aws_ecs_task_definition.cfola_mockserver.arn
desired_count = 1
launch_type = "FARGATE"
depends_on = [
aws_lb_listener.cfola_svc,
aws_service_discovery_service.cfola
]
service_registries {
registry_arn = aws_service_discovery_service.mockserver.arn
}
network_configuration {
security_groups = [var.config.secgrps.svc.id]
subnets = data.aws_subnet_ids.private_subnet_ids.ids
assign_public_ip = true
}
}
However in both Cloud Map and Route53 all of the services appear in the cfola private DNS namespace rather than the 2 services appearing in “cfola” and the 1 appearing in “mockserver”
I have also tried just referencing everything into the cfola private DNS namespace but it doesn’t pull in the mockserver name - it just puts everything as cfola.cfola.local and everything is referenced under the cfola.local Cloud Map.
Is this a bug? Is there any work around for this?