From 0307f8ffb8176044c518b738b864d2d39cfab61f Mon Sep 17 00:00:00 2001 From: Jan Egil Ring Date: Fri, 18 Mar 2022 20:57:09 +0100 Subject: [PATCH] Added support for installing Azure Monitor agent #4 Signed-off-by: Jan Egil Ring --- ext_azure_monitor.tf | 9 +++++++++ variables.tf | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 ext_azure_monitor.tf diff --git a/ext_azure_monitor.tf b/ext_azure_monitor.tf new file mode 100644 index 0000000..b77dbfd --- /dev/null +++ b/ext_azure_monitor.tf @@ -0,0 +1,9 @@ +resource "azurerm_virtual_machine_extension" "azure_monitor_agent" { + count = var.azure_monitor_agent ? 1 : 0 + name = local.os_type == "windows" ? "AzureMonitorWindowsAgent" : "AzureMonitorLinuxAgent" + virtual_machine_id = local.os_type == "windows" ? azurerm_windows_virtual_machine.machine[0].id : azurerm_linux_virtual_machine.machine[0].id + publisher = "Microsoft.Azure.Monitor" + type = local.os_type == "windows" ? "AzureMonitorWindowsAgent" : "AzureMonitorLinuxAgent" + type_handler_version = local.os_type == "windows" ? "1.2" : "1.15" + tags = var.tags +} diff --git a/variables.tf b/variables.tf index a99d310..9e8987d 100644 --- a/variables.tf +++ b/variables.tf @@ -167,3 +167,9 @@ variable "azure_ad_join" { type = bool default = false } + +variable "azure_monitor_agent" { + description = "Whether to install the Azure Monitor Agent VM extension." + type = bool + default = false +}