Skip to content

Commit

Permalink
Merge pull request #1 from Azure-Terraform/sanitize
Browse files Browse the repository at this point in the history
Sanitize
  • Loading branch information
jhisc authored Jul 7, 2020
2 parents 54ac796 + c31e1d0 commit 579b4b3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 50 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ The Delegated zone will be created using the Azure subscription name

| Name | Version |
|------|---------|
| azurerm | >= 2.0.0 >= 2.0.0 |
| azurerm.iog | >= 2.0.0 >= 2.0.0 |
| azurerm.child | >= 2.0.0 >= 2.0.0 |
| azurerm.parent | >= 2.0.0 >= 2.0.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
| domain\_prefix | Zone prefix | `string` | n/a | yes |
| iog\_resource\_group\_name | Name of the parent subscription - This is the owner of the root domain | `string` | n/a | yes |
| iog\_subscription\_id | ID of the parent subscription - This is the owner of the root domain | `string` | n/a | yes |
| names | Names to be applied to resources (inclusive) | <pre>object({<br> environment = string<br> location = string<br> market = string<br> product_name = string<br> })</pre> | n/a | yes |
| sre\_resource\_group\_name | Name of the target resource group | `string` | n/a | yes |
| sre\_subscription\_id | ID of the target subscription | `string` | n/a | yes |
| child\_domain\_prefix | child domain prefix (<child>.<domain>.<prefix>.<parent domain>) | `string` | n/a | yes |
| child\_domain\_resource\_group\_name | Name of the target resource group | `string` | n/a | yes |
| child\_domain\_subscription\_id | ID of the target subscription | `string` | n/a | yes |
| parent\_domain | parent domain | `string` | n/a | yes |
| parent\_domain\_resource\_group\_name | Name of the parent resource\_group - This is the owner of the root domain | `string` | n/a | yes |
| parent\_domain\_subscription\_id | ID of the parent subscription - This is the owner of the parent domain | `string` | n/a | yes |
| tags | Tags to be applied to resources (inclusive) | `map(string)` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| id | id of dns child zone |
| name | The DNS zone that has been delegated to you |
<!--- END_TF_DOCS --->
24 changes: 10 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@

# SRE Resources
resource "azurerm_dns_zone" "sre" {
name = "${lower(var.domain_prefix)}.lnrisk.io"
resource_group_name = var.sre_resource_group_name
resource "azurerm_dns_zone" "child" {
provider = azurerm.child
name = "${lower(var.child_domain_prefix)}.${lower(var.parent_domain)}"
resource_group_name = var.child_domain_resource_group_name
tags = var.tags
}

# IOG Resources
resource "azurerm_dns_ns_record" "iog" {

provider = azurerm.iog
name = lower(var.domain_prefix)
zone_name = "lnrisk.io"
resource_group_name = var.iog_resource_group_name
resource "azurerm_dns_ns_record" "child" {
provider = azurerm.parent
name = lower(var.child_domain_prefix)
zone_name = lower(var.parent_domain)
resource_group_name = var.parent_domain_resource_group_name
ttl = 300
tags = var.tags

records = azurerm_dns_zone.sre.name_servers

records = azurerm_dns_zone.child.name_servers
}
11 changes: 8 additions & 3 deletions output.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
output "id" {
description = "id of dns child zone"
value = azurerm_dns_zone.child.id
}

output "name" {
value = "${lower(var.domain_prefix)}.lnrisk.io"
value = "${lower(var.child_domain_prefix)}.${lower(var.parent_domain)}"
description = "The DNS zone that has been delegated to you"
depends_on = [
# ensure resources are created prior to outputs
azurerm_dns_ns_record.iog,
azurerm_dns_zone.sre
azurerm_dns_ns_record.child,
azurerm_dns_zone.child
]
}
35 changes: 13 additions & 22 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
# SRE Subscription
## This should be the output of the subscription module
variable "sre_subscription_id" {
variable "child_domain_subscription_id" {
description = "ID of the target subscription"
type = string
}

variable "sre_resource_group_name" {
variable "child_domain_resource_group_name" {
description = "Name of the target resource group"
type = string
}

# IOG Subscription
variable "iog_subscription_id" {
description = "ID of the parent subscription - This is the owner of the root domain"
variable "child_domain_prefix" {
description = "child domain prefix (<child>.<domain>.<prefix>.<parent domain>)"
type = string
}

variable "iog_resource_group_name" {
description = "Name of the parent subscription - This is the owner of the root domain"
variable "parent_domain_subscription_id" {
description = "ID of the parent subscription - This is the owner of the parent domain"
type = string
}

# Domain
variable "domain_prefix" {
description = "Zone prefix"
variable "parent_domain_resource_group_name" {
description = "Name of the parent resource_group - This is the owner of the root domain"
type = string
}

variable "parent_domain" {
description = "parent domain"
type = string
}

# Meta Data
variable "tags" {
description = "Tags to be applied to resources (inclusive)"
type = map(string)
}

variable "names" {
description = "Names to be applied to resources (inclusive)"
type = object({
environment = string
location = string
market = string
product_name = string
})
}
7 changes: 4 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ terraform {
}

provider "azurerm" {
alias = "child"
subscription_id = var.child_domain_subscription_id
version = ">= 2.0.0"
features {}
subscription_id = var.sre_subscription_id
}

provider "azurerm" {
alias = "parent"
subscription_id = var.parent_domain_subscription_id
version = ">= 2.0.0"
features {}
alias = "iog"
subscription_id = var.iog_subscription_id
}

0 comments on commit 579b4b3

Please sign in to comment.