Skip to content

Commit

Permalink
adding dnszone ex1
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash-keloth committed Dec 14, 2020
1 parent 2c7e7c6 commit c07e14d
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 99 deletions.
2 changes: 1 addition & 1 deletion container_registry.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ output azure_container_registries {
value = module.container_registry
sensitive = true
}

20 changes: 10 additions & 10 deletions diagnostics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ locals {

# Remote amd locally created diagnostics objects
combined_diagnostics = {
diagnostics_definition = try(var.diagnostics.diagnostics_definition, {})
diagnostics_destinations = try(var.diagnostics.diagnostics_destinations, {})
storage_accounts = merge(try(var.diagnostics.storage_accounts, {}), module.diagnostic_storage_accounts)
log_analytics = merge(try(var.diagnostics.log_analytics, {}), module.diagnostic_log_analytics)
event_hub_namespaces = merge(try(var.diagnostics.event_hub_namespaces, {}), module.diagnostic_event_hub_namespaces)
diagnostics_definition = try(var.diagnostics.diagnostics_definition, {})
diagnostics_destinations = try(var.diagnostics.diagnostics_destinations, {})
storage_accounts = merge(try(var.diagnostics.storage_accounts, {}), module.diagnostic_storage_accounts)
log_analytics = merge(try(var.diagnostics.log_analytics, {}), module.diagnostic_log_analytics)
event_hub_namespaces = merge(try(var.diagnostics.event_hub_namespaces, {}), module.diagnostic_event_hub_namespaces)
}
}

Expand All @@ -38,11 +38,11 @@ module "diagnostic_event_hub_namespaces" {
source = "./modules/event_hub_namespaces"
for_each = local.diagnostics.diagnostic_event_hub_namespaces

global_settings = local.global_settings
settings = each.value
resource_groups = module.resource_groups
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
global_settings = local.global_settings
settings = each.value
resource_groups = module.resource_groups
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
}

module diagnostic_event_hub_namespaces_diagnostics {
Expand Down
16 changes: 8 additions & 8 deletions event_hub_namespaces.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module "event_hub_namespaces" {
source = "./modules/event_hub_namespaces"
for_each = var.event_hub_namespaces

global_settings = local.global_settings
settings = each.value
resource_groups = module.resource_groups
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
global_settings = local.global_settings
settings = each.value
resource_groups = module.resource_groups
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
}

module event_hub_namespaces_diagnostics {
Expand All @@ -27,8 +27,8 @@ module event_hub_namespaces_diagnostics {

module event_hub_namespaces_private_endpoints {
depends_on = [module.event_hub_namespaces]
source = "./modules/networking/private_endpoint"
for_each = local.event_hub_namespaces_private_endpoints
source = "./modules/networking/private_endpoint"
for_each = local.event_hub_namespaces_private_endpoints

resource_id = each.value.id
name = each.value.settings.name
Expand All @@ -41,7 +41,7 @@ module event_hub_namespaces_private_endpoints {
}

locals {
event_hub_namespaces_private_endpoints = {
event_hub_namespaces_private_endpoints = {
for private_endpoint in
flatten(
[
Expand Down
2 changes: 1 addition & 1 deletion examples/networking/dns_zones/configuration.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource_groups = {

dns_zones = {
dns_zone1 = {
name = "terraatsg.com"
name = "testdomainxyzabc.com"
region = "region1"
resource_group_key = "dns_re1"

Expand Down
12 changes: 6 additions & 6 deletions front_doors.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module "front_doors" {
source = "./modules/networking/front_door"
for_each = local.networking.front_doors
for_each = local.networking.front_doors

global_settings = local.global_settings
settings = each.value
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
global_settings = local.global_settings
settings = each.value
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
resource_group_name = module.resource_groups[each.value.resource_group_key].name
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
tags = try(local.global_settings.inherit_tags, false) ? merge(module.resource_groups[each.value.resource_group_key].tags, try(each.value.tags, null)) : try(each.value.tags, null)
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
tags = try(local.global_settings.inherit_tags, false) ? merge(module.resource_groups[each.value.resource_group_key].tags, try(each.value.tags, null)) : try(each.value.tags, null)
}
40 changes: 2 additions & 38 deletions modules/networking/dns_zone/dns_zone.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "azurerm_dns_zone" "domain_zone" {
name = var.settings.name
resource_group_name = var.resource_group_name
tags = var.tags
tags = local.tags
}

resource "azurerm_template_deployment" "domain" {
Expand Down Expand Up @@ -54,40 +54,4 @@ resource "azurerm_management_lock" "lock_domain" {
scope = azurerm_template_deployment.domain.outputs.resourceID
lock_level = "CanNotDelete"
notes = "Deleting a domain will make it unavailable to purchase for 60 days. Please remove the lock before deleting this domain."
}

resource "azurerm_dns_cname_record" "target" {
name = "target"
zone_name = azurerm_dns_zone.domain_zone.name
resource_group_name = var.resource_group_name
ttl = 300
record = "forfrontdoor.azurefd.net"
}

# module "dns_records" {
# # source = "terraformdns/dns-recordsets/azurerm"

# resource_group_name = var.resource_group_name
# dns_zone_name = azurerm_dns_zone.domain_zone.name
# recordsets = [
# {
# name = "www"
# type = "A"
# ttl = 3600
# records = [
# "192.0.2.56",
# ]
# },
# {
# name = ""
# type = "TXT"
# ttl = 3600
# records = [
# "\"v=spf1 ip4:192.0.2.3 include:backoff.${aws_route53_zone.example.name} -all\"",
# ]
# },

# ]
# }


}
1 change: 1 addition & 0 deletions modules/networking/dns_zone/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ locals {
"module" = basename(abspath(path.module))
}
arm_filename = "${path.module}/arm_domain.json"
tags = merge(local.module_tag, try(var.settings.tags, null), var.base_tags)
}
34 changes: 5 additions & 29 deletions modules/networking/dns_zone/variables.tf
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@

variable resource_group_name {
description = "(Required) The name of the resource group in which to create the Container Registry. Changing this forces a new resource to be created."
}

variable location {
description = "(Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created."
}

variable resource_group_name {}
variable location {}
variable settings {}
variable global_settings {}
variable base_tags {}
variable contract {}
variable tags {}
variable contract {
default = {}
}
variable name {
description = "(Required) Name of the Domain to be created"
type = string
default = "terra.com"
}

# variable contract {
# description = "(Required) contract fields for the domain name registration"
# type = object({
# name_first = string
# name_last = string
# email = string
# phone = string
# job_title = string
# address1 = string
# address2 = string
# postal_code = string
# state = string
# city = string
# country = string
# auto_renew = bool
# })
# }

variable lock_zone {
description = "(Required) Determines to put a Azure lock after creating the zone"
type = bool
Expand Down
3 changes: 0 additions & 3 deletions networking_dns_zones.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ module dns_zones {

settings = each.value
global_settings = local.global_settings
contract = each.value.contract
# name = each.value.name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
resource_group_name = module.resource_groups[each.value.resource_group_key].name
tags = try(each.value.tags, null)
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
}

Expand Down
6 changes: 3 additions & 3 deletions virtual_machines.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@


module virtual_machines {
source = "./modules/compute/virtual_machine"
source = "./modules/compute/virtual_machine"
depends_on = [
module.keyvault_access_policies,
module.keyvault_access_policies,
module.keyvault_access_policies_azuread_apps,
module.dynamic_keyvault_secrets
]
for_each = local.compute.virtual_machines
for_each = local.compute.virtual_machines

global_settings = local.global_settings
client_config = local.client_config
Expand Down

0 comments on commit c07e14d

Please sign in to comment.