DNS Service
The DNS service: zones and records, in any cloud provider’s DNS.
The platform uses DNSService, through
smarter.apps.infrastructure.services.infrastructure .dns, and the provider’s DNS
is an implementation of it, e.g.
Route53DNSService.
A provider implements only the primitives, the abstract _ methods. The operations that the
platform needs, e.g. DNSService.create_domain_a_record(), are built on them here, once,
along with their signals, so that they behave the same in every cloud.
Zones and records are DNSZone and DNSRecord, whatever the provider’s own
representation. Names never have a trailing dot.
- class smarter.apps.infrastructure.services.dns.DNSRecord(name, type, ttl=None, values=<factory>, alias=None)[source]
Bases:
objectA DNS record set: the values of one name and type.
- __init__(name, type, ttl=None, values=<factory>, alias=None)
- alias: dict[str, Any] | None = None
A provider-specific alias target, e.g. an AWS load balancer, in place of values.
- class smarter.apps.infrastructure.services.dns.DNSService(provider_name, *args, **kwargs)[source]
Bases:
InfrastructureServiceThe DNS service of a cloud provider.
- Parameters:
provider_name (
str) – The name of the provider, e.g.aws.
- billable_zones: bool = True
Whether the provider bills for zones, e.g. AWS Route53 bills each hosted zone monthly.
- create_domain_a_record(hostname, api_host_domain, zone_id=None)[source]
Point a host at the same target as a parent domain, by copying the parent’s A record.
e.g. an LLMClient’s host,
example.3141-5926-5359.api.smarter.sh, points at the load balancer ofapi.smarter.sh.- Parameters:
hostname (
str) – The host, e.g.example.3141-5926-5359.api.smarter.sh.api_host_domain (
str) – The parent domain whose A record is copied, e.g.api.smarter.sh. The record is created in its zone, unlesszone_idis given.zone_id (
Optional[str]) – The zone in which to create the record, e.g. a custom domain’s.
- Return type:
- Returns:
The record, and whether it was created.
- Raises:
DNSZoneNotFound – If the parent domain has no A record.
- delete_zone(domain)[source]
Delete the zone of a domain, and all of its records.
This cannot be undone.
- property environment_api_domain: str
The environment’s API domain, as it exists in DNS, e.g.
local.api.example.com.In the local environment,
smarter_settings.environment_api_domainis a localhost domain, which DNS cannot serve, so this is its proxy domain.
- error_class
alias of
DNSServiceError
- get_environment_a_record(domain=None)[source]
Return the A record of a domain, in its own zone: by default, the environment’s domain.
The A record of a Smarter environment’s domain points at its load balancer. The platform copies it to the hosts that it serves, e.g. each LLMClient’s.
- get_name_servers(zone_id)[source]
Return the name servers of a zone, e.g. for a customer to delegate their domain to.
- Parameters:
zone_id (
str) – The provider’s id of the zone.- Return type:
- Returns:
The name servers, without trailing dots.
- Raises:
DNSZoneNotFound – If the zone does not exist.
- get_or_create_record(zone_id, name, record_type, ttl=600, values=None, alias=None)[source]
Return a record, and create it, or update its values, if it does not match.
- Parameters:
- Return type:
- Returns:
The record, and whether it was created, rather than found or updated.
- Raises:
DNSRecordTimeout – If the record does not appear in the zone in time.
- get_or_create_zone(domain)[source]
Return the zone of a domain, and create it if it does not exist.
A new zone is billable in most clouds, so it is announced with
billable_resource_creatingandbillable_resource_created.
- resolve_domain(domain)[source]
Validate a domain, and replace a local environment’s API domain with its proxy domain.
- resolve_record_name(name)[source]
Resolve a record’s name, as
resolve_domain()does, but without validating it as a host name.Record names may contain labels that host names may not, e.g.
_acme-challenge.example.com.- Return type:
- service_name: str = 'dns'
The name of the service in signals and logs, see
InfrastructureServiceNames.