Creates an AWS VPC and a Service Discovery service with a private DNS namespace.

Terraform Template

resource "aws_service_discovery_private_dns_namespace" "example" {
  description = "example"
  name = "example.terraform.local"
  vpc = aws_vpc.example.id
}

resource "aws_service_discovery_service" "example" {

  dns_config {

    dns_records {
      ttl = 10
      type = "A"
    }
    namespace_id = aws_service_discovery_private_dns_namespace.example.id
    routing_policy = "MULTIVALUE"
  }

  health_check_custom_config {
    failure_threshold = 1
  }
  name = "example"
}

resource "aws_vpc" "example" {
  cidr_block = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support = true
}