-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVOPS-280 loganalytics terraform module initial commit (#10)
* DEVOPS-280 loganalytics terraform module initial commit * DEVOPS-280 loganalytics terraform module initial commit
- Loading branch information
1 parent
d428fc0
commit 3023d2a
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "azurerm_resource_group" "rg" { | ||
name = upper(var.resource_group_name) | ||
location = var.location | ||
tags = { | ||
Environment = upper(var.environment) | ||
Orchestrator = "Terraform" | ||
DisplayName = upper(var.resource_group_name) | ||
ApplicationName = lower(var.application_name) | ||
} | ||
} | ||
|
||
resource "azurerm_log_analytics_workspace" "loganalytics_ws" { | ||
name = upper(var.loganalytics_workspace_name) | ||
sku = var.loganalytics_sku | ||
resource_group_name = azurerm_resource_group.rg.name | ||
location = var.location | ||
retention_in_days = var.loganalytics_retention_period | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "loganalytics_workspace_name" { | ||
value = azurerm_log_analytics_workspace.loganalytics_ws.name | ||
description = "Azure Log analytics workspace name" | ||
} | ||
|
||
output "loganalytics_workspace_resource_group" { | ||
value = azurerm_log_analytics_workspace.loganalytics_ws.resource_group_name | ||
description = "Azure Log analytics workspace resource group name" | ||
} | ||
|
||
output "loganalytics_retention_period" { | ||
value = azurerm_log_analytics_workspace.loganalytics_ws.retention_in_days | ||
description = "Azure loganalytics data retention in days" | ||
} | ||
|
||
output "loganalytics_sku" { | ||
value = azurerm_log_analytics_workspace.loganalytics_ws.sku | ||
description = "Azure loganalytics SKU" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_version = "~> 1.3" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "<= 4.0" | ||
} | ||
} | ||
} | ||
provider "azurerm" { | ||
features {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
variable "resource_group_name" { | ||
default = "" | ||
description = "Azure resource group name to create log analytics workspace" | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
default = "" | ||
description = "Azure location" | ||
type = string | ||
} | ||
|
||
variable "loganalytics_workspace_name" { | ||
default = "" | ||
type = string | ||
description = "Loganalytics workspace name" | ||
} | ||
|
||
variable "loganalytics_retention_period" { | ||
default = 7 | ||
description = "Loganalytics logs retention period" | ||
type = number | ||
validation { | ||
condition = var.loganalytics_retention_period == 7 || (var.loganalytics_retention_period >= 30 && var.loganalytics_retention_period <= 730) | ||
error_message = "The workspace data retention in days. Possible values are either 7 (Free Tier only) or range between 30 and 730." | ||
} | ||
|
||
} | ||
|
||
variable "application_name" { | ||
default = "" | ||
description = "Azure application name tag" | ||
type = string | ||
} | ||
|
||
variable "environment" { | ||
default = "" | ||
description = "Environment tag value in Azure" | ||
type = string | ||
validation { | ||
condition = contains(["DEV", "QA", "UAT", "PROD"], var.environment) | ||
error_message = "Environment value should be one among DEV or QA or UAT or PROD." | ||
} | ||
} | ||
|
||
variable "loganalytics_sku" { | ||
default = "PerGB2018" | ||
type = string | ||
description = "Specifies the SKU of the Log Analytics Workspace" | ||
validation { | ||
condition = contains(["PerNode", "Premium", "Standard", "Standalone", "Unlimited", "CapacityReservation", "PerGB2018"], var.loganalytics_sku) | ||
error_message = "Log analytics SKU should be one among PerNode, Premium, Standard, Standalone, Unlimited, CapacityReservation or PerGB2018 ." | ||
} | ||
} | ||
|