Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag issue LogicApp (Standard) + VM extensions #33

Merged
merged 23 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion logic_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ module "logic_app_standard" {
private_dns = local.combined_objects_private_dns
vnets = local.combined_objects_networking
virtual_subnets = local.combined_objects_virtual_subnets
base_tags = try(local.global_settings.inherit_tags, false)
#base_tags = try(local.global_settings.inherit_tags, false)
vnet_integration = try(each.value.vnet_integration, {})
combined_objects = local.dynamic_app_settings_combined_objects
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)
}

output "logic_app_standard" {
Expand Down
1 change: 1 addition & 0 deletions modules/compute/virtual_machine_extensions/AADLogin.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resource "azurerm_virtual_machine_extension" "AADLogin" {
type = local.aadlogin_type
type_handler_version = var.extension.type_handler_version
auto_upgrade_minor_version = true
tags = merge(local.tags, try(each.value.tags, null))
}

locals {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "azurerm_virtual_machine_extension" "linux_diagnostic" {
type_handler_version = try(var.extension.type_handler_version, "4.0")
automatic_upgrade_enabled = try(var.extension.auto_upgrade_minor_version, false)
auto_upgrade_minor_version = try(var.extension.auto_upgrade_minor_version, true)
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode({
"ladCfg" = jsondecode(templatefile(local.linux_diagnostic.ladcfg, { virtual_machine_id = var.virtual_machine_id }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "azurerm_virtual_machine_extension" "monitoring" {
publisher = "Microsoft.EnterpriseCloud.Monitoring"
type = "MicrosoftMonitoringAgent"
type_handler_version = "1.0"
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resource "azurerm_virtual_machine_extension" "custom_script" {
type = local.type
type_handler_version = local.type_handler_version
auto_upgrade_minor_version = true
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ resource "azurerm_virtual_machine_extension" "devops_selfhosted_agent" {
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.1"
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(local.devops_selfhosted_agent_settings)
protected_settings = jsonencode(local.devops_selfhosted_agent_protected_settings)
Expand Down
1 change: 1 addition & 0 deletions modules/compute/virtual_machine_extensions/domain_join.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resource "azurerm_virtual_machine_extension" "domainjoin" {
type = "JsonADDomainExtension"
type_handler_version = try(var.extension.type_handler_version, "1.3")
auto_upgrade_minor_version = try(var.extension.auto_upgrade_minor_version, true)
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ resource "azurerm_virtual_machine_extension" "genext" {
auto_upgrade_minor_version = try(each.value.auto_upgrade_minor_version, null)
automatic_upgrade_enabled = try(each.value.automatic_upgrade_enabled, null)
failure_suppression_enabled = try(each.value.failure_suppression_enabled, null)
tags = merge(local.tags, try(each.value.tags, null))

settings = try(each.value.settings, null)
protected_settings = try(each.value.protected_settings, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resource "azurerm_virtual_machine_extension" "keyvault_for_windows" {
type = "KeyVaultForWindows"
type_handler_version = try(var.extension.type_handler_version, "1.0")
auto_upgrade_minor_version = try(var.extension.auto_upgrade_minor_version, true)
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
16 changes: 16 additions & 0 deletions modules/compute/virtual_machine_extensions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ data "azurecaf_environment_variable" "token" {

name = var.extension.pats_from_env_variable.variable_name
fails_if_empty = true
}

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)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resource "azurerm_virtual_machine_extension" "diagnostics" {
type = "IaaSDiagnostics"
type_handler_version = try(var.extension.type_handler_version, "1.9")
auto_upgrade_minor_version = try(var.extension.auto_upgrade_minor_version, true)
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "azurerm_virtual_machine_extension" "tfcloud_selfhosted_agent" {
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.1"
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(local.tfcloud_selfhosted_agent_settings)
protected_settings = jsonencode(local.tfcloud_selfhosted_agent_protected_settings)
Expand Down
12 changes: 11 additions & 1 deletion modules/compute/virtual_machine_extensions/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ variable "storage_accounts" {
}
variable "virtual_machine_os_type" {
default = {}
}
}
variable "base_tags" {
description = "Base tags for the resource to be inherited from the resource group."
type = bool
}
variable "global_settings" {
description = "Global settings object (see module README.md)"
}
variable "resource_group" {
description = "Resource group object to deploy the virtual machine"
}
1 change: 1 addition & 0 deletions modules/compute/virtual_machine_extensions/wvd_dsc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resource "azurerm_virtual_machine_extension" "session_host_dscextension" {
type = "DSC"
type_handler_version = "2.73"
auto_upgrade_minor_version = true
tags = merge(local.tags, try(each.value.tags, null))

settings = jsonencode(
{
Expand Down
16 changes: 15 additions & 1 deletion modules/logic_app/standard/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ terraform {
}

locals {
resource_group = var.resource_groups[try(var.settings.lz_key, var.settings.resource_group.lz_key, var.client_config.landingzone_key)][try(var.settings.resource_group.key, var.settings.resource_group_key)]
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)
)
location = coalesce(var.location, var.resource_group.location)
resource_group_name = coalesce(var.resource_group_name, var.resource_group.name)
storage_account = var.storage_accounts[try(var.settings.lz_key, var.settings.storage_account.lz_key, var.client_config.landingzone_key)][try(var.settings.storage_account.key, var.settings.storage_account_key)]
app_service_plan = var.app_service_plans[try(var.settings.app_service_plan.lz_key, var.settings.lz_key, var.client_config.landingzone_key)][try(var.settings.app_service_plan.key, var.settings.app_service_plan_key)]
app_settings = var.external_app_settings == true ? null : try(var.app_settings, null)
Expand Down
7 changes: 4 additions & 3 deletions modules/logic_app/standard/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ resource "azurecaf_name" "logic_app_standard_name" {

resource "azurerm_logic_app_standard" "logic_app_standard" {
name = azurecaf_name.logic_app_standard_name.result
location = lookup(var.settings, "region", null) == null ? local.resource_group.location : var.global_settings.regions[var.settings.region]
resource_group_name = local.resource_group.name
location = local.location
resource_group_name = local.resource_group_name
app_service_plan_id = local.app_service_plan.id
storage_account_name = local.storage_account.name
storage_account_access_key = local.storage_account.primary_access_key
https_only = try(var.settings.https_only, null)
tags = merge(local.tags, try(var.settings.tags, {}))

app_settings = local.app_settings

Expand Down Expand Up @@ -64,4 +65,4 @@ resource "azurerm_app_service_virtual_network_swift_connection" "vnet_config" {
app_service_id = azurerm_logic_app_standard.logic_app_standard.id
subnet_id = can(var.vnet_integration.subnet_id) ? var.vnet_integration.subnet_id : try(var.vnets[try(var.vnet_integration.lz_key, var.client_config.landingzone_key)][var.vnet_integration.vnet_key].subnets[var.vnet_integration.subnet_key].id,
try(var.virtual_subnets[var.client_config.landingzone_key][var.vnet_integration.subnet_key].id, var.virtual_subnets[var.vnet_integration.lz_key][var.vnet_integration.subnet_key].id))
}
}
4 changes: 2 additions & 2 deletions modules/logic_app/standard/private_endpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module "private_endpoint" {

resource_id = azurerm_logic_app_standard.logic_app_standard.id
name = each.value.name
location = lookup(var.settings, "region", null) == null ? local.resource_group.location : var.global_settings.regions[var.settings.region]
resource_group_name = local.resource_group.name
location = local.location
resource_group_name = local.resource_group_name
subnet_id = coalesce(
try(each.value.subnet_id, null),
try(var.vnets[var.client_config.landingzone_key][each.value.vnet_key].subnets[each.value.subnet_key].id, null),
Expand Down
18 changes: 18 additions & 0 deletions modules/logic_app/standard/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ variable "external_app_settings" {

variable "dynamic_app_settings" {
default = {}
}

variable "resource_group" {
description = "Resource group object to deploy the virtual machine"
}

variable "tags" {
default = null
}

variable "resource_group_name" {
description = "Resource group object to deploy the virtual machine"
default = null
}

variable "location" {
description = "(Required) Resource Location"
default = null
}
30 changes: 30 additions & 0 deletions virtual_machines_extensions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module "vm_extension_monitoring_agent" {
virtual_machine_id = module.virtual_machines[each.key].id
extension = each.value.virtual_machine_extensions.microsoft_enterprise_cloud_monitoring
extension_name = "microsoft_enterprise_cloud_monitoring"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
settings = {
diagnostics = local.combined_diagnostics
}
Expand All @@ -31,6 +34,9 @@ module "vm_extension_diagnostics" {
virtual_machine_id = module.virtual_machines[each.key].id
extension = each.value.virtual_machine_extensions.microsoft_azure_diagnostics
extension_name = "microsoft_azure_diagnostics"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
settings = {
var_folder_path = var.var_folder_path
diagnostics = local.combined_diagnostics
Expand All @@ -52,6 +58,9 @@ module "vm_extension_microsoft_azure_domainjoin" {
extension = each.value.virtual_machine_extensions.microsoft_azure_domainjoin
extension_name = "microsoft_azure_domainJoin"
keyvaults = local.combined_objects_keyvaults
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
}

module "vm_extension_session_host_dscextension" {
Expand All @@ -69,6 +78,9 @@ module "vm_extension_session_host_dscextension" {
extension_name = "session_host_dscextension"
keyvaults = local.combined_objects_keyvaults
wvd_host_pools = local.combined_objects_wvd_host_pools
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
}

module "vm_extension_custom_scriptextension" {
Expand All @@ -88,6 +100,9 @@ module "vm_extension_custom_scriptextension" {
extension_name = "custom_script"
managed_identities = local.combined_objects_managed_identities
storage_accounts = local.combined_objects_storage_accounts
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
}

module "vm_extension_generic" {
Expand All @@ -102,6 +117,9 @@ module "vm_extension_generic" {
virtual_machine_os_type = module.virtual_machines[each.key].os_type
extension = each.value.virtual_machine_extensions.generic_extensions
extension_name = "generic_extension"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
}

module "keyvault_for_windows" {
Expand All @@ -119,6 +137,9 @@ module "keyvault_for_windows" {
extension = each.value.virtual_machine_extensions.keyvault_for_windows
extension_name = "keyvault_for_windows"
keyvaults = local.combined_objects_keyvaults
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]
}

module "vm_extension_linux_diagnostic" {
Expand All @@ -133,6 +154,9 @@ module "vm_extension_linux_diagnostic" {
virtual_machine_id = module.virtual_machines[each.key].id
extension = each.value.virtual_machine_extensions.linux_diagnostic
extension_name = "linux_diagnostic"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]

settings = {
var_folder_path = var.var_folder_path
Expand All @@ -153,6 +177,9 @@ module "vm_extensions_devops_selfhosted_agent" {
virtual_machine_id = module.virtual_machines[each.key].id
extension = each.value.virtual_machine_extensions.devops_selfhosted_agent
extension_name = "devops_selfhosted_agent"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]

settings = {
devops_selfhosted_agent = {
Expand Down Expand Up @@ -181,6 +208,9 @@ module "vm_extensions_tfcloud_selfhosted_agent" {
virtual_machine_id = module.virtual_machines[each.key].id
extension = each.value.virtual_machine_extensions.tfcloud_selfhosted_agent
extension_name = "tfcloud_selfhosted_agent"
base_tags = local.global_settings.inherit_tags
global_settings = local.global_settings
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)]

settings = {
tfcloud_selfhosted_agent = {
Expand Down
Loading