# azure-terraform/terraform-azurerm-dns-zone architecture

> Architecture diagram of the GitHub repository azure-terraform/terraform-azurerm-dns-zone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure-terraform/terraform-azurerm-dns-zone
- Repository: https://github.com/azure-terraform/terraform-azurerm-dns-zone
- Video tour (about a minute): https://gitdiagram.com/azure-terraform/terraform-azurerm-dns-zone/video

## Overview

##### Project type and purpose
- This is an Infrastructure-as-Code (IaC) Terraform module designed to automate the creation of a delegated DNS zone in Azure.
- It manages two Azure subscriptions (parent and child), creates a child DNS zone in the child subscription, and inserts NS records into an existing parent DNS zone in the parent subscription.

##### File structure
- Top-level Terraform files:
- provider.tf – configures azurerm.child and azurerm.parent providers
- versions.tf – declares Terraform version and provider version constraints
- variables.tf – defines module inputs (child/parent subscription IDs, RG names, domain prefixes, tags)
- main.tf – declares Azure DNS zone and NS record resources
- output.tf – exposes module outputs (zone id, name, RG, subscription)
- main.tf, output.tf complement each other to produce the module’s public interface.
- CI configuration:
- .github/workflows/documentation.yml – GitHub Action to build docs (no runtime pipeline here).

##### README for additional insights
- The module uses two named providers to operate across subscriptions.
- Inputs and outputs are well documented – this helps highlight the boundaries of the module.
- Example usage shows how a consumer invokes the module, passing in RG names, subscription IDs, domain names, and tags.

##### Elements
- Clear labels: e.g., “Terraform CLI,” “azurerm.parent provider,” “Parent Subscription,” “Parent DNS Zone,” “azurerm.child provider,” “Child Subscription,” “Child DNS Zone,” “NS Record Delegation.”
- From Terraform → azurerm.parent → Fetch/Read Parent DNS Zone
- From Terraform → azurerm.child → Create Child DNS Zone
- From Terraform → azurerm.parent → Create NS Record
- Rectangle (blue) for Terraform components (CLI, providers)

##### Detailed breakdown
- one labeled “data.azurerm_dns_zone.read” pointing to “Parent DNS Zone,”
- one labeled “azurerm_dns_ns_record.create” pointing to “Parent DNS Zone.”
8. At the bottom, list module inputs feeding into Terraform (variables.tf) and outputs feeding back to caller (output.tf).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Terraform Orchestration
    subgraph "Terraform CLI" 
        direction TB
        TFCLI["Terraform CLI"]:::terraform
        PARENT_PROV["azurerm.parent provider"]:::terraform
        CHILD_PROV["azurerm.child provider"]:::terraform
    end

    %% Azure Subscriptions and Resources
    subgraph "Azure Parent Subscription" 
        direction TB
        parentSub["Parent Subscription"]:::azure
        parentRG["Parent RG"]:::azure
        parentZone["Parent DNS Zone"]:::azure
    end

    subgraph "Azure Child Subscription" 
        direction TB
        childSub["Child Subscription"]:::azure
        childRG["Child RG"]:::azure
        childZone["Child DNS Zone"]:::azure
    end

    %% Module Interface
    subgraph "Module Interface" 
        direction TB
        inputs["Module Inputs"]:::docs
        outputs["Module Outputs"]:::docs
        versions["Version Constraints"]:::docs
    end

    %% CI and Documentation
    CI["GitHub Actions: documentation.yml"]:::docs
    README["Module README"]:::docs
    LICENSE["LICENSE"]:::docs

    %% Connections
    TFCLI --> PARENT_PROV
    TFCLI --> CHILD_PROV

    PARENT_PROV -.->|data.azurerm_dns_zone.read| parentZone
    CHILD_PROV -->|create azurerm_dns_zone| childZone
    PARENT_PROV -->|create azurerm_dns_ns_record| parentZone

    parentSub --> parentRG --> parentZone
    childSub --> childRG --> childZone

    inputs --> TFCLI
    TFCLI --> outputs
    versions --> TFCLI

    CI --> TFCLI
    README --> inputs
    README --> outputs
    LICENSE --> README

    %% Click Events
    click TFCLI "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/main.tf"
    click PARENT_PROV "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/provider.tf"
    click CHILD_PROV "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/provider.tf"
    click parentZone "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/main.tf"
    click childZone "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/main.tf"
    click inputs "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/variables.tf"
    click outputs "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/output.tf"
    click versions "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/versions.tf"
    click CI "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/.github/workflows/documentation.yml"
    click README "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/README.md"
    click LICENSE "https://github.com/azure-terraform/terraform-azurerm-dns-zone/blob/master/LICENSE.md"

    %% Styles
    classDef terraform fill:#D0E1F9,stroke:#0366d6;
    classDef azure fill:#e6f4ea,stroke:#34a853;
    classDef docs fill:#f1f8e9,stroke:#8bc34a;
    classDef data stroke-dasharray: 5 5;
```
