Skip to content

Commit

Permalink
Updating vnet and pip
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudlh committed Mar 20, 2023
1 parent 204d75e commit ed78753
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
14 changes: 3 additions & 11 deletions modules/networking/public_ip_addresses/main.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
locals {
module_tag = {
"module" = basename(abspath(path.module))
}
tags = var.base_tags ? merge(
var.global_settings.tags,
try(var.resource_group.tags, null),
local.module_tag,
try(var.tags, null)
) : merge(
local.module_tag,
try(var.tags,
null)
)
) : try(var.tags, null)

location = var.resource_group.location
resource_group_name = var.resource_group.name
location = coalesce(var.location, var.resource_group.location)
resource_group_name = coalesce(var.resource_group_name, var.resource_group.name)
}
2 changes: 1 addition & 1 deletion modules/networking/public_ip_addresses/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource "azurerm_public_ip" "pip" {
domain_name_label = var.generate_domain_name_label ? var.name : var.domain_name_label
reverse_fqdn = var.reverse_fqdn
availability_zone = var.zones
tags = merge(local.tags, try(var.tags, {}))
tags = local.tags
public_ip_prefix_id = var.public_ip_prefix_id
ip_tags = var.ip_tags
}
14 changes: 11 additions & 3 deletions modules/networking/public_ip_addresses/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ variable "name" {
description = "(Required) Specifies the name of the Public IP resource . Changing this forces a new resource to be created."
type = string
}
variable "resource_group" {
description = "(Required) The name of the resource group where to create the resource."
}
variable "sku" {
description = "(Optional) The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic."
type = string
Expand Down Expand Up @@ -107,6 +104,17 @@ variable "public_ip_prefix_id" {
type = string
}

variable "location" {
description = "location of the resource if different from the resource group."
default = null
}
variable "resource_group_name" {
description = "Resource group object to deploy the virtual machine"
default = null
}
variable "resource_group" {
description = "Resource group object to deploy the virtual machine"
}
variable "base_tags" {
description = "Base tags for the resource to be inherited from the resource group."
type = bool
Expand Down
16 changes: 4 additions & 12 deletions modules/networking/virtual_network/main.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
locals {
module_tag = {
"module" = basename(abspath(path.module))
}
tags = var.base_tags ? merge(
var.global_settings.tags,
try(var.resource_group.tags, null),
local.module_tag,
try(var.settings.tags, null)
) : merge(
local.module_tag,
try(var.settings.tags,
null)
)
try(var.tags, null)
) : try(var.tags, null)

location = var.resource_group.location
resource_group_name = var.resource_group.name
location = coalesce(var.location, var.resource_group.location)
resource_group_name = coalesce(var.resource_group_name, var.resource_group.name)
}

terraform {
Expand Down
2 changes: 1 addition & 1 deletion modules/networking/virtual_network/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "azurerm_virtual_network" "vnet" {
location = local.location
resource_group_name = local.resource_group_name
address_space = var.settings.vnet.address_space
tags = merge(local.tags, try(var.settings.tags, {}))
tags = local.tags

dns_servers = flatten(
concat(
Expand Down
25 changes: 16 additions & 9 deletions modules/networking/virtual_network/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
variable "client_config" {}
variable "resource_group" {
description = "(Required) Name of the resource group where to create the resource. Changing this forces a new resource to be created. "
}

variable "tags" {
description = "(Required) map of tags for the deployment"
}
Expand Down Expand Up @@ -38,18 +34,29 @@ variable "route_tables" {
variable "global_settings" {
description = "Global settings object (see module README.md)"
}
variable "base_tags" {
description = "Base tags for the resource to be inherited from the resource group."
type = bool
}
variable "network_watchers" {
default = {}
}
variable "network_security_groups" {
default = {}
description = "Network Security Group cretaed with different Resource Group"
}

variable "remote_dns" {
default = {}
}

variable "location" {
description = "location of the resource if different from the resource group."
default = null
}
variable "resource_group_name" {
description = "Resource group object to deploy the virtual machine"
default = null
}
variable "resource_group" {
description = "Resource group object to deploy the virtual machine"
}
variable "base_tags" {
description = "Base tags for the resource to be inherited from the resource group."
type = bool
}
13 changes: 9 additions & 4 deletions networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ module "networking" {
settings = each.value
tags = try(each.value.tags, null)

resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)]
base_tags = local.global_settings.inherit_tags
base_tags = local.global_settings.inherit_tags
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)]
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : null
location = try(local.global_settings.regions[each.value.region], null)


#assumed from remote lz only to prevent circular references
Expand Down Expand Up @@ -123,8 +125,6 @@ module "public_ip_addresses" {
for_each = local.networking.public_ip_addresses

name = azurecaf_name.public_ip_addresses[each.key].result
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)]
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
sku = try(each.value.sku, "Basic")
allocation_method = try(each.value.allocation_method, "Dynamic")
Expand All @@ -143,6 +143,11 @@ module "public_ip_addresses" {
)
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
diagnostics = local.combined_diagnostics

base_tags = local.global_settings.inherit_tags
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)]
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : null
location = try(local.global_settings.regions[each.value.region], null)
}

#
Expand Down

0 comments on commit ed78753

Please sign in to comment.