From 5052d0f6a55381a1ff48a5fc9c312b3eb513be24 Mon Sep 17 00:00:00 2001 From: lisamurphy-msft <87032539+lisamurphy-msft@users.noreply.github.com> Date: Wed, 22 Sep 2021 10:18:48 -0400 Subject: [PATCH] Update tags to append DeploymentType in terraform (#422) --- src/terraform/mlz/main.tf | 72 +++++++------------------------- src/terraform/mlz/variables.tf | 13 +++--- src/terraform/tier3/main.tf | 10 +---- src/terraform/tier3/variables.tf | 14 +++---- 4 files changed, 31 insertions(+), 78 deletions(-) diff --git a/src/terraform/mlz/main.tf b/src/terraform/mlz/main.tf index 370596bc7..dc47c088a 100644 --- a/src/terraform/mlz/main.tf +++ b/src/terraform/mlz/main.tf @@ -138,21 +138,15 @@ resource "azurerm_resource_group" "hub" { location = var.mlz_location name = var.hub_rgname - - tags = { - DeploymentName = var.deploymentname - } -} + tags = var.tags +} resource "azurerm_resource_group" "tier0" { provider = azurerm.tier0 location = var.mlz_location name = var.tier0_rgname - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_resource_group" "tier1" { @@ -160,10 +154,7 @@ resource "azurerm_resource_group" "tier1" { location = var.mlz_location name = var.tier1_rgname - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_resource_group" "tier2" { @@ -171,10 +162,7 @@ resource "azurerm_resource_group" "tier2" { location = var.mlz_location name = var.tier2_rgname - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } ################################ @@ -198,10 +186,7 @@ resource "azurerm_log_analytics_workspace" "laws" { location = var.mlz_location sku = "PerGB2018" retention_in_days = "30" - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_log_analytics_solution" "laws_sentinel" { @@ -218,10 +203,7 @@ resource "azurerm_log_analytics_solution" "laws_sentinel" { publisher = "Microsoft" product = "OMSGallery/SecurityInsights" } - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } ############################### @@ -241,10 +223,7 @@ module "hub-network" { management_address_space = var.hub_management_address_space log_analytics_workspace_resource_id = azurerm_log_analytics_workspace.laws.id - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } module "firewall" { @@ -272,10 +251,7 @@ module "firewall" { management_publicip_name = var.management_publicip_name log_analytics_workspace_resource_id = azurerm_log_analytics_workspace.laws.id - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } module "spoke-network-t0" { @@ -295,10 +271,7 @@ module "spoke-network-t0" { spoke_vnetname = var.tier0_vnetname spoke_vnet_address_space = var.tier0_vnet_address_space subnets = var.tier0_subnets - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_virtual_network_peering" "t0-to-hub" { @@ -342,10 +315,7 @@ module "spoke-network-t1" { spoke_vnetname = var.tier1_vnetname spoke_vnet_address_space = var.tier1_vnet_address_space subnets = var.tier1_subnets - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_virtual_network_peering" "t1-to-hub" { @@ -389,10 +359,7 @@ module "spoke-network-t2" { spoke_vnetname = var.tier2_vnetname spoke_vnet_address_space = var.tier2_vnet_address_space subnets = var.tier2_subnets - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_virtual_network_peering" "t2-to-hub" { @@ -454,10 +421,7 @@ module "jumpbox-subnet" { log_analytics_workspace_id = azurerm_log_analytics_workspace.laws.workspace_id log_analytics_workspace_location = var.mlz_location log_analytics_workspace_resource_id = azurerm_log_analytics_workspace.laws.id - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } module "bastion-host" { @@ -473,10 +437,7 @@ module "bastion-host" { subnet_address_prefix = var.bastion_address_space public_ip_name = var.bastion_public_ip_name ipconfig_name = var.bastion_ipconfig_name - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } module "jumpbox" { @@ -508,10 +469,7 @@ module "jumpbox" { linux_offer = var.jumpbox_linux_vm_offer linux_sku = var.jumpbox_linux_vm_sku linux_image_version = var.jumpbox_linux_vm_version - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } ##################################### diff --git a/src/terraform/mlz/variables.tf b/src/terraform/mlz/variables.tf index c158a9751..b8783ebaf 100644 --- a/src/terraform/mlz/variables.tf +++ b/src/terraform/mlz/variables.tf @@ -11,12 +11,6 @@ variable "tf_environment" { default = "public" } -variable "deploymentname" { - description = "A name for the deployment. It defaults to dev." - type = string - default = "dev" -} - variable "mlz_tenantid" { description = "The Azure Active Directory tenant ID that should be used for the deployment." type = string @@ -59,6 +53,13 @@ variable "create_assignment" { default = false } +variable "tags" { + description = "A map of key value pairs to apply as tags to resources provisioned in this deployment" + type = map(string) + default = { + "DeploymentType" : "MissionLandingZoneTF" + } +} ################################# # Hub Configuration ################################# diff --git a/src/terraform/tier3/main.tf b/src/terraform/tier3/main.tf index cf8e260a6..b4077f07f 100644 --- a/src/terraform/tier3/main.tf +++ b/src/terraform/tier3/main.tf @@ -95,10 +95,7 @@ resource "azurerm_resource_group" "tier3" { location = var.mlz_location name = var.tier3_rgname - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } ################################ @@ -139,10 +136,7 @@ module "spoke-network-t3" { spoke_vnetname = var.tier3_vnetname spoke_vnet_address_space = var.tier3_vnet_address_space subnets = var.tier3_subnets - - tags = { - DeploymentName = var.deploymentname - } + tags = var.tags } resource "azurerm_virtual_network_peering" "t3-to-hub" { diff --git a/src/terraform/tier3/variables.tf b/src/terraform/tier3/variables.tf index 1b1914b5b..c1f7d5529 100644 --- a/src/terraform/tier3/variables.tf +++ b/src/terraform/tier3/variables.tf @@ -10,12 +10,6 @@ variable "tf_environment" { default = "public" } -variable "deploymentname" { - description = "A name for the deployment. It defaults to dev." - type = string - default = "dev" -} - variable "mlz_tenantid" { description = "The Azure Active Directory tenant ID that should be used for the deployment." type = string @@ -51,7 +45,13 @@ variable "mlz_objectid" { type = string sensitive = true } - +variable "tags" { + description = "A map of key value pairs to apply as tags to resources provisioned in this deployment" + type = map(string) + default = { + "DeploymentType" : "MissionLandingZoneTF" + } +} ################################# # Hub Configuration #################################