> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensor9.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Endpoints, DNS, and Load Balancing

Tensor9 BYOC manages DNS hostnames, load balancers, and TLS certificates across cloud and Kubernetes environments. When you define these resources in your [origin stack](https://docs.tensor9.com/byoc/fundamentals/origin-stacks.md), Tensor9 BYOC compiles them to the appropriate [service adapter](https://docs.tensor9.com/byoc/service-adapters/overview.md) for the target [form factor](https://docs.tensor9.com/byoc/fundamentals/key-concepts.md#form-factor). This includes private Kubernetes clusters where cloud-managed services aren't available.

You can also assign publicly-accessible custom DNS hostnames to deployed [appliances](https://docs.tensor9.com/byoc/fundamentals/appliances.md) by configuring a **vanity domain** for your app. This enables touch-free SSL certificate generation and branded endpoints for your customers.

There are two ways to assign vanity domains to appliances:

1. **Vendor-Supplied**: Tensor9 BYOC automatically assigns subdomains of the app's root vanity domain to customers (e.g., `customer-a.ai-chat.playground.tensor9.app`).
2. **Customer-Supplied**: Your customer brings their own domain (e.g., `app.internal.customer.com`) and delegates it to the appliance.

In both cases, your Terraform origin stack remains exactly the same. Tensor9 BYOC creates the hosted zone during appliance setup *before* the deployment stack is deployed. The deployment stack simply looks up the pre-existing zone to create records.

## Service-adapter report endpoints

AWS-origin service operations and explanation retrieval use separate service clients. Keep S3, DynamoDB and other operations on their configured native service clients. Configure a separate client for Tensor9's synthetic AWS `t9` service to retrieve and acknowledge explanation reports.

Use the `t9` endpoint and signing region belonging to the same install as the original request. The compiled deployment supplies them to the workload as `T9_ENDPOINT_URL` and `T9_SIGNING_REGION`. Configure the report client from those values; they select the destination and origin AWS signing region while credentials continue to come from the workload's IAM credential provider. Local `tensor9 adapt svc run` readiness output supplies the corresponding `t9 endpoint` and `t9 signing region` values (`t9Endpoint` and `t9SigningRegion` in JSON output). Do not derive the endpoint from an S3 URL, a vanity domain or the report ID, or substitute another customer's install. The report client uses regular IAM credentials for the original authenticated request owner and SigV4 signing service `t9`. A local forwarded URL may be shared by more than one service; the signing name still selects `t9`.

The `t9` API uses AWS JSON 1.1 requests to `POST /`, without a query string. Its signed `X-Amz-Target` header selects `T9CloudAdapter.GetExplanation` or `T9CloudAdapter.AcknowledgeExplanation`. These requests are separate from the application's origin-service calls and from the BYOC control-plane CLI login. Follow [Debugging Service Adapters](https://docs.tensor9.com/byoc/service-adapters/debugging/overview.md#configure-the-report-client) for request bodies, receipt handling and ownership.

The developer CLI's [existing-report read](https://docs.tensor9.com/byoc/service-adapters/debugging/overview.md#retrieve-an-existing-report-with-the-developer-cli) accepts these exact connection values as `-t9Endpoint` and `-t9SigningRegion`, or reads their published environment variables. It uses normal AWS credentials for the original report owner; it needs no control-plane login or Tensor9 API key.

## Enable Vanity Domains

To enable vanity domains, specify a root domain during app creation:

**1. Specify a vanity domain during app creation**

```bash theme={null}
tensor9 app create \
  -name ai-chat \
  -vanityDomain ai-chat.playground.tensor9.app
```

This triggers Tensor9 BYOC to create a hosted zone for this domain. The vanity domain is scoped to the app and all installs of this app share the same root domain.

**2. One-time manual delegation**

Perform a one-time manual delegation from your DNS provider to the nameservers of the hosted zone created by Tensor9 BYOC. This allows Tensor9 BYOC to manage subdomains on your behalf.

## Vanity Domain Assignment

Once the app is created with a vanity domain, your customers can choose to use either the vendor-supplied or customer-supplied vanity domain option during appliance setup.

### Vendor-Supplied Domains

In this model, Tensor9 BYOC automatically manages the assignment and delegation of a subdomain of your app's root vanity domain to an appliance.

When a customer installs your app, Tensor9 BYOC automatically:

**1. Assigns a unique subdomain**

Tensor9 BYOC assigns a unique subdomain to the install (e.g., `customer-a.ai-chat.playground.tensor9.app`).

**2. Creates a hosted zone**

The appliance setup process creates a hosted zone for this subdomain within the customer's environment.

**3. Delegates the subdomain**

Tensor9 BYOC delegates the subdomain from your root hosted zone to the appliance's hosted zone.

### Customer-Supplied Domains

In this model, your customer brings their own domain name.

**1. Customer provides domain**

During appliance setup, the customer specifies their desired domain (e.g., `portal.corp.com`).

**2. Zone creation**

The appliance setup process creates a hosted zone for this domain within the customer's environment.

**3. Customer delegation**

The customer adds an NS record at their DNS provider to delegate the domain to their appliance's hosted zone.

## DNS Provider Support

Tensor9 BYOC uses the **native DNS service** of each target environment where possible. For environments without a built-in DNS service, Tensor9 BYOC supports external DNS providers.

| Target Environment | DNS Provider | Notes |
| - | - | - |
| AWS | Route 53 | Native AWS DNS service |
| Google Cloud | Cloud DNS | Native GCP DNS service |
| Azure | Azure DNS | Native Azure DNS service |
| Private Kubernetes | Route 53 or Cloudflare | External DNS provider configured during appliance setup |

Your origin stack doesn't change based on the DNS provider. During compilation, Tensor9 BYOC handles provider selection automatically based on the target form factor.

> [!NOTE]
>
> For private Kubernetes appliances, the DNS provider is configured at the appliance level. Credentials are stored securely, never leave the customer's environment, and are used by Tensor9 BYOC to manage DNS records on their behalf.

## Origin Stack: DNS

To support both vanity domain workflows, your Terraform code should **look up** a hosted zone rather than create one.

### 1. Receive the Domain Name

Use the `@vanity_domain_root()` annotation on a variable. Tensor9 BYOC injects the install's assigned fully qualified domain name (FQDN) at deploy time.

```hcl theme={null}
# @vanity_domain_root()
variable "domain_root" {
  type        = string
  default     = "local.example.com"
}
```

### 2. Look Up the Hosted Zone

Reference the hosted zone using a Terraform **data source** instead of a resource. The zone already exists (created during appliance setup) by the time your stack is deployed.

```hcl AWS theme={null}
data "aws_route53_zone" "app_zone" {
  name = var.domain_root
}

resource "aws_route53_record" "app" {
  zone_id = data.aws_route53_zone.app_zone.zone_id
  name    = "www.${var.domain_root}"
  type    = "CNAME"
  ttl     = 300
  records = [aws_lb.app.dns_name]
}
```

```hcl GCP theme={null}
data "google_dns_managed_zone" "app_zone" {
  name = var.domain_root
}

resource "google_dns_record_set" "app" {
  managed_zone = data.google_dns_managed_zone.app_zone.name
  name         = "www.${var.domain_root}."
  type         = "CNAME"
  ttl          = 300
  rrdatas      = [google_compute_global_address.app.address]
}
```

```hcl Azure theme={null}
data "azurerm_dns_zone" "app_zone" {
  name = var.domain_root
}

resource "azurerm_dns_cname_record" "app" {
  name                = "www"
  zone_name           = data.azurerm_dns_zone.app_zone.name
  resource_group_name = var.resource_group_name
  ttl                 = 300
  record              = azurerm_public_ip.app.fqdn
}
```

During compilation, all DNS records are compiled to use the DNS provider configured on the appliance. For private Kubernetes targets, Route 53 and Cloudflare records are managed automatically via the configured DNS provider.

## Load Balancer Endpoints

Tensor9 BYOC compiles load balancer resources from your origin stack to equivalent resources in the target environment using the [service adapters](https://docs.tensor9.com/byoc/service-adapters/overview.md) model. For example, you can define load balancers using AWS resources, and Tensor9 BYOC will map them to Kubernetes-native load balancing when compiling for private environments.

### How It Works

Vendors define load balancer resources in their origin stack using AWS convention. During compilation, Tensor9 BYOC:

**1. Identifies load balancer resources**

Tensor9 BYOC detects the use of NLBs, ALBs, or Kubernetes Services with AWS Load Balancer Controller annotations and Ingress resources with load balancer annotations.

**2. Maps to target equivalents**

Each load balancer resource is mapped to its functional equivalent based on the target form factor.

**3. Preserves configuration**

Port mappings, health checks, routing rules, and TLS settings are preserved in the mapping.

**4. Manages dependencies**

Required infrastructure (Traefik, cert-manager) is declared as service dependencies and installed automatically in the customer's environment.

### Equivalence Table

| Origin (AWS) | Private Kubernetes | Notes |
| - | - | - |
| Kubernetes Service with NLB annotations | Kubernetes Service with MetalLB annotations | L4 TCP/UDP load balancing |
| Kubernetes Ingress with ALB annotations | Traefik IngressRoute | L7 HTTP/HTTPS routing |
| Health check annotations | Kubernetes probes | Automatic mapping |
| ACM certificate (via annotation) | cert-manager Certificate | See [TLS Certificates](#tls-certificates) |

> [!NOTE]
>
> You do not need to define Traefik or cert-manager resources in your origin stack. Tensor9 BYOC automatically declares these as service dependencies and manages their installation in the target environment.

### Origin Stack Example

Here is a typical Kubernetes service with AWS NLB annotations from an AWS origin stack:

```hcl theme={null}
resource "kubernetes_service_v1" "app" {
  metadata {
    name      = "app-lb"
    namespace = var.namespace

    annotations = {
      "service.beta.kubernetes.io/aws-load-balancer-type"   = "nlb"
      "service.beta.kubernetes.io/aws-load-balancer-scheme" = "internet-facing"
    }
  }

  spec {
    type = "LoadBalancer"

    port {
      port        = 443
      target_port = 8080
      protocol    = "TCP"
    }

    selector = {
      app = "my-app"
    }
  }
}
```

When compiled for a private Kubernetes form factor, Tensor9 BYOC replaces the AWS annotations with MetalLB annotations and adds the necessary service dependency declarations. The port mappings and selectors are preserved.

### `@kubernetes_service()` Annotation

Use `@kubernetes_service(type='LoadBalancer')` on a `data "kubernetes_service_v1"` data source when your stack needs to reference a load balancer service's external address. This annotation tells the compiler how to handle platform-specific behavior. For example, MetalLB assigns IP addresses (not hostnames), so the compiler creates a DNS A record and rewrites `.hostname` references accordingly.

```hcl theme={null}
# @kubernetes_service(type='LoadBalancer')
data "kubernetes_service_v1" "traefik" {
  metadata {
    name      = "traefik"
    namespace = "traefik"
  }
}

resource "aws_route53_record" "app" {
  zone_id = data.aws_route53_zone.app_zone.zone_id
  name    = "app.${var.domain_root}"
  type    = "CNAME"
  ttl     = 300
  records = [data.kubernetes_service_v1.traefik.status.0.load_balancer.0.ingress.0.hostname]
}
```

## TLS Certificates

Tensor9 BYOC compiles TLS certificate resources to the appropriate equivalent for each target environment. In AWS, certificates are managed by ACM. In private Kubernetes environments, Tensor9 BYOC uses [cert-manager](https://cert-manager.io/) with Let's Encrypt DNS-01 validation.

### Origin Stack: ACM Certificates

Define TLS certificates using AWS ACM resources. Since the vanity domain is properly delegated, you can use automatic DNS validation:

```hcl theme={null}
resource "aws_acm_certificate" "cert" {
  domain_name       = "www.${var.domain_root}"
  validation_method = "DNS"
}

resource "aws_route53_record" "cert_validation" {
  for_each = {
    for dvo in aws_acm_certificate.cert.domain_validation_options : dvo.domain_name => {
      name   = dvo.resource_record_name
      record = dvo.resource_record_value
      type   = dvo.resource_record_type
    }
  }

  allow_overwrite = true
  name            = each.value.name
  records         = [each.value.record]
  ttl             = 60
  type            = each.value.type
  zone_id         = data.aws_route53_zone.app_zone.zone_id
}

resource "aws_acm_certificate_validation" "cert" {
  certificate_arn         = aws_acm_certificate.cert.arn
  validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
}
```

### Equivalence: cert-manager

When compiling for private Kubernetes, Tensor9 BYOC replaces ACM resources with cert-manager equivalents:

| Origin (AWS) | Private Kubernetes | Notes |
| - | - | - |
| `aws_acm_certificate` | cert-manager `Certificate` CRD | Domain name and SANs preserved |
| `aws_acm_certificate_validation` | Removed | cert-manager handles validation automatically |
| `aws_route53_record` (validation) | Removed | DNS-01 challenge handled by cert-manager solver |

The cert-manager `ClusterIssuer` is managed automatically by Tensor9 BYOC's service dependency system and vendors do not need to define it. The issuer uses Let's Encrypt with DNS-01 validation via the appliance's configured DNS provider.

### Referencing External Certificates

When an ACM certificate is passed as a variable (rather than defined in-stack), the compiler cannot follow the reference to extract domain information. Instead, use a `data "aws_acm_certificate"` data source to look up the certificate by domain. This allows Tensor9 BYOC to extract the domain information and automatically convert it to a Kubernetes data source when compiling for private Kubernetes.

```hcl theme={null}
# @vanity_domain_root()
variable "domain_root" {
  description = "Root domain name (e.g., example.com)"
  type        = string
}

data "aws_acm_certificate" "cert" {
  domain   = var.domain_root
  statuses = ["ISSUED"]
}
```

## Annotations Reference

| Annotation | Applies To | Description |
| - | - | - |
| `@vanity_domain_root()` | `variable` | Injects the install's vanity domain FQDN at deploy time |
| `@vanity_domain_provided()` | `variable` (bool) | Controls conditional hosted zone creation (see below) |
| `@kubernetes_service(type='LoadBalancer')` | `data "kubernetes_service_v1"` | Marks a load balancer data source for platform-specific handling |

### Additional Annotations

#### @vanity\_domain\_provided()

If you need to keep the hosted zone definition inside your origin stack (e.g., for self-contained single-file stacks), use `@vanity_domain_provided()` to handle this conditionally.

Annotate a boolean variable with `@vanity_domain_provided()`. Leave it `false` (the default) so the hosted zone is created when you deploy the stack directly.

During compilation, Tensor9 BYOC sets the variable to `true` to skip hosted zone creation (since it was created during appliance setup) and allows the deployment stack to look up the zone instead.

```hcl theme={null}
# @vanity_domain_provided()
variable "zone_provided" {
  type    = bool
  default = false
}

# Conditionally create the zone ONLY if it wasn't provided
resource "aws_route53_zone" "created_zone" {
  count = var.zone_provided ? 0 : 1
  name  = var.domain_root
}

# Look up the zone if it WAS provided
data "aws_route53_zone" "lookup_zone" {
  count = var.zone_provided ? 1 : 0
  name  = var.domain_root
}
```

## Best Practices

> [accordion] Purchase a separate root domain
>
> If your app is hosted at `saas.com`, pick an alternative like
> `saas-customers.com` or `saas.app` for your vanity domain root. This ensures that the cookie space for your
> hosted offering is entirely separate from your customer's appliances.

> [accordion] Keep the root domain as brief as possible
>
> The maximum length of the Common Name in a certificate is 64 characters. Vanity
> domains assigned to customers include the appliance ID as well as any
> endpoints defined in your origin stack. The total length of the
> subdomain for which a certificate is requested cannot exceed the limit.

> [accordion] Use data sources for hosted zones
>
> Always reference hosted zones using data sources (`data "aws_route53_zone"`) instead of creating them with resources. The zone is created during appliance setup before your stack is deployed. Using a data source ensures your stack works with both vendor-supplied and customer-supplied vanity domains.

> [accordion] Let Tensor9 BYOC manage load balancer equivalence
>
> Do not manually define Traefik or cert-manager resources in your origin stack. Use standard AWS load balancer annotations and ACM certificates. Tensor9 BYOC compiles these to the correct equivalents for each target environment and manages the required infrastructure automatically.

## Questions You Might Ask

> [accordion] How do vendor-supplied and customer-supplied vanity domains differ?
>
> Both modes create a DNS hosted zone in the customer's cloud account during appliance setup, and
> both flow through the same
> [`@vanity_domain_root()`](https://docs.tensor9.com/byoc/fundamentals/endpoints#1-receive-the-domain-name) variable in your origin stack.
> Your origin stack does not need to distinguish between the two.
>
> The difference is in who owns the domain and who performs the NS delegation:
>
> * **Vendor-supplied**: You register a domain (e.g., `your-domain.app`) and delegate it to Tensor9 BYOC.
>   Tensor9 BYOC auto-generates a subdomain for each customer (e.g., `abc123.your-domain.app`) and
>   handles NS delegation to the customer's hosted zone automatically.
> * **Customer-supplied**: The customer provides their own domain during appliance setup and
>   creates the NS delegation on their side. Tensor9 BYOC configures the customer's hosted zone accordingly.

> [accordion] Where is the customer's hosted zone created?
>
> In the customer's cloud account, during appliance setup. For vendor-supplied domains, Tensor9 BYOC
> then delegates the subdomain from your app's root hosted zone (in your Tensor9 BYOC Cloud Account)
> to the customer's hosted zone by creating NS records automatically. For customer-supplied
> domains, the customer handles NS delegation themselves.
>
> Here is the delegation chain for vendor-supplied domains:
>
> ![NS delegation from your domain registrar through your Tensor9 BYOC Cloud Account to the customer hosted zone.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/vanity-domain-dns-wide-dark.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=d5ab385a40d50a48d5f2233b2805eb20)
>
> ![NS delegation from your domain registrar through your Tensor9 BYOC Cloud Account to the customer hosted zone.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/vanity-domain-dns-wide-light.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=f7220d1f474ebf685e3774a1ef8ae72c)
>
> ![NS delegation from your domain registrar through your Tensor9 BYOC Cloud Account to the customer hosted zone.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/vanity-domain-dns-stacked-dark.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=fd8cbfafe2538c4c8f45552c405e67b1)
>
> ![NS delegation from your domain registrar through your Tensor9 BYOC Cloud Account to the customer hosted zone.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/vanity-domain-dns-stacked-light.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=417fe2379c79b53b0a3674a74e20636b)
>
> Your domain registrar delegates to the Tensor9 BYOC-managed hosted zone in your Tensor9 BYOC Cloud Account.
> Tensor9 BYOC then delegates each customer's subdomain to their own hosted zone in their account.
> Dashed arrows show NS delegation; application traffic does not pass through these DNS zones.

> [accordion] Who creates the TLS certificates for each customer?
>
> You define a TLS certificate resource once in your origin stack, referencing the
> [`@vanity_domain_root()`](https://docs.tensor9.com/byoc/fundamentals/endpoints#1-receive-the-domain-name) annotated domain variable.
> Tensor9 BYOC compiles that resource into each customer's deployment with the correct domain and the
> appropriate certificate type for the target environment (e.g., AWS ACM certificates on AWS,
> cert-manager Certificates on Kubernetes). This works the same for both vendor-supplied and
> customer-supplied domains.
>
> Do not hardcode certificate identifiers - the compiler operates on Terraform resources, not raw strings.

> [accordion] Do TLS certificates live in our account or the customer's account?
>
> In the customer's account, alongside the load balancers and CDN distributions that reference them.
> DNS validation records are created in the customer's hosted zone during deployment. Because
> the subdomain is delegated to the customer's zone, certificate authorities can resolve the
> validation records through the delegation chain.
>
> ![Customer-owned DNS validation records, TLS certificate and load balancer; a certificate authority resolves validation records through DNS delegation.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/acm-cert-flow-wide-dark.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=27fa3f7b28a7f6bf576bde12fcfd16fd)
>
> ![Customer-owned DNS validation records, TLS certificate and load balancer; a certificate authority resolves validation records through DNS delegation.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/acm-cert-flow-wide-light.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=5cf469bbaf8b2f7ccae950aeafb3b1a7)
>
> ![Customer-owned DNS validation records, TLS certificate and load balancer; a certificate authority resolves validation records through DNS delegation.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/acm-cert-flow-stacked-dark.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=7b37bcb166df3fea96b0796bf77ecf81)
>
> ![Customer-owned DNS validation records, TLS certificate and load balancer; a certificate authority resolves validation records through DNS delegation.](https://mintcdn.com/tensor9/JMtEGFvqIUHHwRjp/images/diagrams/acm-cert-flow-stacked-light.svg?fit=max\&auto=format\&n=JMtEGFvqIUHHwRjp\&q=85\&s=73b7f6e9ec3c2ad863698d931a3e3b73)
>
> Dashed arrows show DNS delegation and certificate validation lookups. The solid arrow shows
> which load balancer uses the customer-owned certificate.

> [accordion] Do I need to create the root hosted zone myself?
>
> No. For vendor-supplied domains, Tensor9 BYOC creates it automatically during app creation. You
> perform a one-time NS delegation so that DNS queries for your vanity domain resolve to the
> Tensor9 BYOC-managed hosted zone. Where you configure that delegation depends on the domain you chose:
>
> * **Root domain** (e.g., `your-domain.app`): Update the NS records at your domain registrar to point
>   to the nameservers Tensor9 BYOC returns.
> * **Subdomain** (e.g., `self-host.your-domain.app`): Create an NS record in whatever DNS provider
>   hosts the parent domain (e.g., your `your-domain.app` zone) delegating the subdomain to the Tensor9 BYOC
>   nameservers.
>
> For customer-supplied domains, the customer creates and delegates their own hosted zone during
> appliance setup.

> [accordion] Can I change the vanity domain after app creation?
>
> No. To use a different vanity domain, create a new app with the desired domain.

> [accordion] Should I use a separate domain for customer deployments?
>
> Yes, for vendor-supplied domains. If your cloud product runs at `your-domain.com`, use a
> separate domain like `your-domain.app` for vanity domains. This keeps the cookie space for
> your cloud offering entirely separate from customer appliances.

## Related Topics

* [**Service adapters**](https://docs.tensor9.com/byoc/service-adapters/overview.md): Full reference for how Tensor9 BYOC maps services across cloud providers
* [**Origin Stacks**](https://docs.tensor9.com/byoc/fundamentals/origin-stacks.md): How to define portable infrastructure code
* [**Deployments**](https://docs.tensor9.com/byoc/fundamentals/deployments.md): How compilation and deployment works
* [**Appliances**](https://docs.tensor9.com/byoc/fundamentals/appliances.md): Deploy to different cloud environments


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.