If it's needed to deploy Azure Log Analytics Solution using Terraform, you can use the following Terraform structure,
resource "azurerm_resource_group" "rg" {
name = "rg-sample"
location = "westus3"
}
resource "azurerm_log_analytics_workspace" "workspace" {
name = "alaw-sample"
location = "${azurerm_resource_group.rg.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
sku = "Free"
}
resource "azurerm_log_analytics_solution" "solution" {
solution_name = "ContainerInsights"
location = "${azurerm_resource_group.rg.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
workspace_resource_id = "${azurerm_log_analytics_workspace.workspace.id}"
workspace_name = "${azurerm_log_analytics_workspace.workspace.name}"
plan {
publisher = "Microsoft"
product = "OMSGallery/ContainerInsights"
}
}
It's possible to deploy an Azure Resource Group, an Azure Log Analytics Workspace and an Azure Log Analytics Solution (for Container Monitoring) using the following command,
terraform init
terraform apply -auto-approve
Unfortunately, list of Azure Log Analytics Solutions is not available in the Terraform provider documentation ๐
Official Terraform Resource Provider page for Azure Log Analytics Solution displays only ContainerInsights example, azurerm_log_analytics_solution
If there is already an Azure Subscription, that has Azure Log Analytics Solutions installed, and it's needed to create a Terraform Module out of it, following command will list the installed Azure Log Analytics Solutions,
# List all log-analytics solutions in the current subscription
az monitor log-analytics solution list
# List all log-analytics solutions for a specific subscription
az monitor log-analytics solution list --subscription ${SUBSCRIPTION_ID}
# List all log-analytics solutions in a resource group
az monitor log-analytics solution list --resource-group ${RESOURCE_GROUP_NAME}
When the command above is executed, it will list the installed Azure Log Analytics Solutions, and it's possible to create a Terraform Module using the output of the command,
resource "azurerm_log_analytics_solution" "solution" {
solution_name = "{Product name from the command output}"
location = "${azurerm_resource_group.rg.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
workspace_resource_id = "${azurerm_log_analytics_workspace.workspace.id}"
workspace_name = "${azurerm_log_analytics_workspace.workspace.name}"
plan {
publisher = "{Publisher name from the command output}"
product = "{Product name from the command output}"
}
}
Note: Before running Azure CLI commands, Log Analytics Solution Extension should be installed; az extension add --name log-analytics-solution