Skip to content

cyber-scot/terraform-azurerm-log-analytics-workspace

Repository files navigation

resource "azurerm_log_analytics_workspace" "law" {
  count                              = try(var.create_new_workspace, null) == true ? 1 : 0
  name                               = try(var.name, null)
  location                           = var.location
  resource_group_name                = var.rg_name
  allow_resource_only_permissions    = try(var.allow_resource_only_permissions, true)
  local_authentication_disabled      = try(var.local_authentication_disabled, true)
  cmk_for_query_forced               = try(var.cmk_for_query_forced, false, null)
  sku                                = title(try(var.sku, null))
  retention_in_days                  = try(var.retention_in_days, null)
  reservation_capacity_in_gb_per_day = var.sku == "CapacityReservation" ? var.reservation_capacity_in_gb_per_day : null
  daily_quota_gb                     = title(var.sku) == "Free" ? "0.5" : try(var.daily_quota_gb, null)
  internet_ingestion_enabled         = try(var.internet_ingestion_enabled, null)
  internet_query_enabled             = try(var.internet_query_enabled, null)
  tags                               = try(var.tags, null)
}

data "azurerm_log_analytics_workspace" "read_created_law" {
  count               = try(var.create_new_workspace, null) == true ? 1 : 0
  name                = element(azurerm_log_analytics_workspace.law.*.name, 0)
  resource_group_name = var.rg_name
}

data "azurerm_log_analytics_workspace" "read_law" {
  count               = try(var.create_new_workspace, null) == false ? 1 : 0
  name                = var.name
  resource_group_name = var.rg_name
}

Requirements

No requirements.

Providers

Name Version
azurerm n/a

Modules

No modules.

Resources

Name Type
azurerm_log_analytics_workspace.law resource
azurerm_log_analytics_workspace.read_created_law data source
azurerm_log_analytics_workspace.read_law data source

Inputs

Name Description Type Default Required
allow_resource_only_permissions Whether users require permissions to resources to view logs bool true no
cmk_for_query_forced Whether or not a Customer Managed Key for the query is forced bool true no
create_new_workspace Whether or not you wish to create a new workspace, if set to true, a new one will be created, if set to false, a data read will be performed on a data source bool n/a yes
daily_quota_gb The amount of gb set for max daily ingetion string "" no
internet_ingestion_enabled Whether internet ingestion is enabled bool null no
internet_query_enabled Whether or not your workspace can be queried from the internet bool null no
local_authentication_disabled Whether local authentication is enabled, defaults to false bool false no
location The location for this resource to be put in string n/a yes
name The name of a log analytics workspace string n/a yes
reservation_capacity_in_gb_per_day The reservation capacity gb per day, can only be used with CapacityReservation SKU string "" no
retention_in_days The number of days for retention, between 7 and 730 string "" no
rg_name The name of the resource group, this module does not create a resource group, it is expecting the value of a resource group already exists string n/a yes
sku The sku of the log analytics workspace string "" no
tags A map of the tags to use on the resources that are deployed with this module. map(string) n/a yes

Outputs

Name Description
law_id The id of the log analytics workspace. If a new log analytic workspace is created, fetch its data id, if one is created, fetch the remote one instead
law_name The name of the log analytics workspace
law_primary_key The primary key of the log analytics workspace. If a new log analytic workspace is created, fetch its data id, if one is created, fetch the remote one instead
law_secondary_key The primary key of the log analytics workspace. If a new log analytic workspace is created, fetch its data id, if one is created, fetch the remote one instead
law_workspace_id The workspace id of the log analytics workspace. If a new log analytic workspace is created, fetch its data id, if one is created, fetch the remote one instead

About

A module used to deploy a log analytics workspace 🪵🕵️

Resources

License

Stars

Watchers

Forks

Packages

No packages published