octodns.source.envvar

Classes

EnvVarSource(id, variable, name[, ttl])

This source allows for environment variables to be embedded at octodns execution time into zones.

Exceptions

EnvVarSourceException

EnvironmentVariableNotFoundException(data)

exception octodns.source.envvar.EnvVarSourceException[source]

Bases: Exception

exception octodns.source.envvar.EnvironmentVariableNotFoundException(data)[source]

Bases: EnvVarSourceException

__init__(data)[source]
class octodns.source.envvar.EnvVarSource(id, variable, name, ttl=60)[source]

Bases: BaseSource

This source allows for environment variables to be embedded at octodns execution time into zones. Intended to capture artifacts of deployment to facilitate operational objectives.

The TXT record generated will only have a single value.

The record name cannot conflict with any other co-existing sources. If this occurs, an exception will be thrown.

Possible use cases include:
  • Embedding a version number into a TXT record to monitor update propagation across authoritative providers.

  • Capturing identifying information about the deployment process to record where and when the zone was updated.

version:

class: octodns.source.envvar.EnvVarSource # The environment variable in question, in this example the username # currently executing octodns variable: USER # The TXT record name to embed the value found at the above # environment variable name: deployuser # The TTL of the TXT record (optional, default 60) ttl: 3600

This source is then combined with other sources in the octodns config file:

zones:
netflix.com.:
sources:
  • yaml

  • version

targets:
  • ultra

  • ns1

SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = {'T', 'X'}
DEFAULT_TTL = 60
__init__(id, variable, name, ttl=60)[source]

Initialize the source.

Parameters:

id (str) – Unique identifier for this source instance. Used in logging and configuration references.

Raises:

NotImplementedError – If required class attributes (log, SUPPORTS_GEO, or SUPPORTS) are not defined in the subclass.

_read_variable()[source]
populate(zone, target=False, lenient=False)[source]

Load DNS records from the source into the provided zone.

This method is responsible for reading DNS data from the source’s backend and adding records to the zone using zone.add_record(). Subclasses must implement this method.

Parameters:
  • zone (octodns.zone.Zone) – The zone to populate with records from this source.

  • target (bool) – If True, the populate call is loading the current state from a target provider (for comparison during sync). If False, loading desired state from a source.

  • lenient (bool) – If True, skip strict record validation and do a “best effort” load of data. This allows some non-best-practice configurations through (e.g., missing trailing dots or unescaped semicolons).

Returns:

When target is True (loading current state), should return True if the zone exists in the target or False if it does not. When target is False (loading desired state), return value is ignored and may be None.

Return type:

bool or None

Raises:

NotImplementedError – This base class method must be overridden by subclasses.

Important

  • Must use zone.add_record() to add records to the zone.

  • Should not modify the zone name or other zone properties.

  • When target=True, must return a boolean indicating zone existence.

  • When lenient=True, should relax validation to handle common non-standard configurations.