verify_dns_configuration

This module verifies AWS Route53 DNS resources required by the Smarter platform.

class smarter.apps.api.management.commands.verify_dns_configuration.Command(*args, **kwargs)[source]

Bases: SmarterCommand

Management command for verifying AWS Route53 DNS resources required by the Smarter platform. The general structure of DNS in AWS Route53 for a Smarter installation is as follows:

  • example.com The root domain with hosted zone in AWS Route53 in the AWS account. This should have been created independently of this code base. This command will only verify that the Hosted Zone for the root domain exists. If it is missing then the command will fail.

  • [platform].example.com The platform domain with hosted zone in AWS Route53 in the AWS account and NS records in the root domain hosted zone delegating to it. This should have been created as part of the Terraform infrastructure provisioning for the platform. But if not, this command will create it and add the necessary NS records to the root domain hosted zone.

  • api.[platform].example.com The API domain for the platform with hosted zone in AWS Route53 in the AWS account and NS records in the platform domain hosted zone delegating to it. This should have been created as part of the Terraform infrastructure provisioning for the platform. But if not, this command will create it and add the necessary NS records to the platform domain hosted zone.

  • local.example.com The local proxy domain with hosted zone in AWS Route53 in the AWS account and NS records in the root domain hosted zone delegating to it.

  • api.local.example.com The local API proxy domain with hosted zone in AWS Route53 in the AWS account and NS records in the local proxy domain hosted zone delegating to it.

  • [alpha].[platform].example.com A non-production platform domain with hosted zone in AWS Route53 in the AWS account and NS records in the root domain hosted zone delegating to it.

  • [alpha].api.[platform].example.com A non-production API domain with hosted zone in AWS Route53 in the AWS account and NS records in the platform domain hosted zone delegating to it.

Usage:

This command is intended to be run during deployment, or in running installations as part of DNS trouble shooting. It is useful for administrators and DevOps engineers as an automated tool to validate and/or repair DNS infrastructure in AWS Route53 for the Smarter platform.

Error Handling and Output:

  • Raises clear exceptions and outputs descriptive error messages if any required DNS resource is missing or misconfigured.

  • Fails gracefully if AWS is not configured, or if the Route53 helper is not initialized.

  • Reports the status of each verification and creation step, making it easy to identify and resolve issues.

See also

smarter.common.helpers.aws.route53.AWSRoute53 - AWS Route53 helper class used for DNS operations. smarter.common.helpers.aws_helpers.aws_helper - AWS helper module for initializing AWS services.

get_any_A_record()[source]

A records all resolve to the same AWS Classic Load Balancer. This is a simple traversal method to look for and retrieve an A record from the AWS Route53 hosted zone for any of the existing domains.

Return type:

dict

handle(*args, **options)[source]

Verify DNS configuration.

log_prefix = '\x1b[1;31msmarter.apps.api.management.commands.verify_dns_configuration.Command()\x1b[0m'
verify_base_dns_config()[source]

Verify the AWS Route53 hosted zones for domains associated with the Smarter platform. This includes any of the following domains depending on the configuration and the environment in which this command is being run:

  • example.com (root domain)

  • platform.example.com (platform domain)

  • api.platform.example.com (api domain)

  • local.example.com (local proxy domain)

  • api.local.example.com (local api proxy domain)

  • alpha.platform.example.com (non-production platform domain)

  • alpha.api.platform.example.com (non-production api domain)

Returns:

list of verified domains

Return type:

list[str]

verify_domain_delegated_from_parent(child_domain, parent_domain, a_record)[source]

Verify the AWS Route53 hosted zone for the child domain. example: api.example.com

  • hosted zone for child_domain should exist.

  • hosted zone should contain A record alias to the AWS Classic Load Balancer.

  • NS records for the child_domain hosted zone should exist in the parent_domain hosted zone.

Parameters:
  • child_domain (str) – the child domain to verify. example: api.example.com

  • parent_domain (str) – the parent domain that should have NS records delegating to the child domain. example: example.com

  • a_record (dict) – an A record to use for verification and creation if needed. This should be an A record alias to the AWS Classic Load Balancer that is serving traffic for the Sm

Returns:

None

verify_root_domain_dns_config()[source]

Verify the AWS Route53 hosted zone for the root domain. ie example.com - hosted zone for root domain should exist. - hosted zone should contain A record alias to the AWS Classic Load Balancer. - hosted zone should contain NS records for the root domain (as is expected for any Hosted Zone).

Returns:

None