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

Update App Insights to not be Classic instance #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions infrastructure/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ module kv './modules/key_vault.bicep' = {
}
}

// Log Analytics Workspace
module log './modules/log_analytics_workspace.bicep' = {
name: 'log'
scope: resourceGroup(rg.name)
params: {
baseName: baseName
location: location
tags: tags
}
}

// App Insights
module appi './modules/application_insights.bicep' = {
name: 'appi'
scope: resourceGroup(rg.name)
params: {
baseName: baseName
location: location
workspaceResourceId: log.outputs.logOut
tags: tags
}
}
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/bicep/modules/application_insights.bicep
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
param baseName string
param location string
param workspaceResourceId string
param tags object

// App Insights
Expand All @@ -9,6 +10,7 @@ resource appinsight 'Microsoft.Insights/components@2020-02-02-preview' = {
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: workspaceResourceId
}

tags: tags
Expand Down
16 changes: 16 additions & 0 deletions infrastructure/bicep/modules/log_analytics_workspace.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
param baseName string
param location string
param tags object

resource log 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
name: 'log-${baseName}'
location: location
properties: {
sku: {
name: 'PerGB2018'
}
}
tags: tags
}

output logOut string = log.id
15 changes: 15 additions & 0 deletions infrastructure/terraform/aml_deploy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ module "key_vault" {
tags = local.tags
}

module "log_analytics_workspace" {
source = "./modules/log-analytics-workspace"

rg_name = module.resource_group.name
location = module.resource_group.location

prefix = var.prefix
postfix = var.postfix
env = var.environment

tags = local.tags
}

# Application insights

module "application_insights" {
Expand All @@ -81,6 +94,8 @@ module "application_insights" {
postfix = var.postfix
env = var.environment

log_analytics_workspace_id = module.log_analytics_workspace.id

tags = local.tags
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource "azurerm_application_insights" "appi" {
location = var.location
resource_group_name = var.rg_name
application_type = "web"
workspace_id = var.log_analytics_workspace_id

tags = var.tags
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ variable "postfix" {
variable "env" {
type = string
description = "Environment prefix"
}
}

variable "log_analytics_workspace_id" {
type = string
description = "Log Analytics Workspace Id"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "azurerm_log_analytics_workspace" "log" {
name = "log-${var.prefix}-${var.postfix}${var.env}"
location = var.location
resource_group_name = var.rg_name
sku = "PerGB2018"

tags = var.tags
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = azurerm_log_analytics_workspace.log.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
variable "rg_name" {
type = string
description = "Resource group name"
}

variable "location" {
type = string
description = "Location of the resource group"
}

variable "tags" {
type = map(string)
default = {}
description = "A mapping of tags which should be assigned to the deployed resource"
}

variable "prefix" {
type = string
description = "Prefix for the module name"
}

variable "postfix" {
type = string
description = "Postfix for the module name"
}

variable "env" {
type = string
description = "Environment prefix"
}