Register Custom Domain
Celery tasks for registering llm_client custom domains.
This module defines Celery tasks for registering custom domains for llm_clients, including creating AWS Route53 hosted zones, ACM certificates, and DNS records, as well as associating domains with accounts.
Main Tasks
- register_custom_domain(account_id, domain_name):
Registers a customer’s custom domain name in AWS Route53 and associates the hosted zone with the account.
Signals
pre_register_custom_domain: Sent before custom domain registration begins.
post_register_custom_domain: Sent after custom domain registration is completed.
Configuration
Celery task behavior (retries, backoff, queue) is controlled by smarter_settings.
Logging
Task execution and domain registration are logged using the smarter logging library, with waffle switches for task and llm_client logging.
Usage
Import this module and call the Celery task as needed to asynchronously register an llm_client custom domain:
register_custom_domain.delay(account_id, domain_name)
- raises LLMClientCustomDomainExists:
If the domain is already registered to another account.
- raises AWSACMCertificateNotFound:
If the ACM certificate for the domain is not found.
- raises AWSACMVerificationNotFound:
If the ACM certificate for the domain is not verified.
- raises Exception:
Any exception during task execution will trigger a retry according to Celery settings.
- smarter.apps.llm_client.tasks.register_custom_domain.register_custom_domain(account_id, domain_name)
Register a customer’s custom domain name in AWS Route53 and associate the Hosted Zone with the account.
This Celery task performs the following steps: 1. Sends a pre-register signal for the custom domain. 2. Checks if the custom domain and certificate already exist and are verified. 3. Ensures the domain is not registered by another account. 4. Creates a Hosted Zone for the custom domain if needed. 5. Associates the Hosted Zone with the account. 6. Creates or retrieves an ACM certificate for the domain. 7. Creates a DNS record for the certificate and triggers verification. 8. Sends a post-register signal for the custom domain.
- Parameters:
account_id (int) – The primary key of the Account for which the custom domain is being registered.
domain_name (str) – The custom domain name to register.
Signals
-------
pre_register_custom_domain (django.dispatch.Signal) – Sent before the custom domain registration begins.
post_register_custom_domain (django.dispatch.Signal) – Sent after the custom domain registration is completed.
- Raises:
LLMClientCustomDomainExists – If the domain is already registered to another account.
AWSACMCertificateNotFound – If the ACM certificate for the domain is not found.
AWSACMVerificationNotFound – If the ACM certificate for the domain is not verified.
Exception – Any exception raised during the registration process will trigger a retry according to Celery settings.