Skip to content

Commit

Permalink
Monitoring changes
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Dec 8, 2023
1 parent 7f238c2 commit 3607b98
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 36 deletions.
8 changes: 4 additions & 4 deletions terraform/api_management_logger.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "azurerm_api_management_named_value" "app_insights_apim_instrumentation_key_named_value" {
provider = azurerm.api_management
name = "${azurerm_application_insights.ai.name}-instrumentationkey"
name = "repository${data.azurerm_application_insights.core.name}-instrumentationkey"
resource_group_name = data.azurerm_api_management.platform.resource_group_name
api_management_name = data.azurerm_api_management.platform.name

display_name = "${azurerm_application_insights.ai.name}-instrumentationkey"
display_name = "repository${data.azurerm_application_insights.core.name}-instrumentationkey"

value = azurerm_application_insights.ai.instrumentation_key
value = data.azurerm_application_insights.core.instrumentation_key

depends_on = [
azurerm_role_assignment.apim_kv_role_assignment
Expand All @@ -20,7 +20,7 @@ resource "azurerm_api_management_logger" "api_management_logger" {
api_management_name = data.azurerm_api_management.platform.name
resource_group_name = data.azurerm_api_management.platform.resource_group_name

resource_id = azurerm_application_insights.ai.id
resource_id = data.azurerm_application_insights.core.id

application_insights {
instrumentation_key = "{{${azurerm_api_management_named_value.app_insights_apim_instrumentation_key_named_value.display_name}}}"
Expand Down
8 changes: 0 additions & 8 deletions terraform/app_insights.tf

This file was deleted.

5 changes: 5 additions & 0 deletions terraform/data.app_insights.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//https://github.com/frasermolyneux/portal-core/blob/main/terraform/app_insights.tf
data "azurerm_application_insights" "core" {
name = "ai-portal-core-${var.environment}-${var.location}-${var.instance}"
resource_group_name = "rg-portal-core-${var.environment}-${var.location}-${var.instance}"
}
10 changes: 0 additions & 10 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ provider "azurerm" {
features {}
}

provider "azurerm" {
alias = "log_analytics"
subscription_id = var.log_analytics_subscription_id

# This is a workload repository so won't have permissions to register providers
skip_provider_registration = true

features {}
}

data "azurerm_client_config" "current" {}

data "azuread_client_config" "current" {}
Expand Down
4 changes: 0 additions & 4 deletions terraform/tfvars/dev.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ dns_subscription_id = "db34f572-8b71-40d6-8f99-f29a27612144"
dns_resource_group_name = "rg-platform-dns-prd-uksouth-01"
dns_zone_name = "xtremeidiots.dev"

log_analytics_subscription_id = "d68448b0-9947-46d7-8771-baa331a3063a"
log_analytics_resource_group_name = "rg-platform-logging-prd-uksouth-01"
log_analytics_workspace_name = "log-platform-prd-uksouth-01"

tags = {
Environment = "dev",
Workload = "portal",
Expand Down
4 changes: 0 additions & 4 deletions terraform/tfvars/prd.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ dns_subscription_id = "db34f572-8b71-40d6-8f99-f29a27612144"
dns_resource_group_name = "rg-platform-dns-prd-uksouth-01"
dns_zone_name = "xtremeidiots.dev"

log_analytics_subscription_id = "d68448b0-9947-46d7-8771-baa331a3063a"
log_analytics_resource_group_name = "rg-platform-logging-prd-uksouth-01"
log_analytics_workspace_name = "log-platform-prd-uksouth-01"

tags = {
Environment = "prd",
Workload = "portal",
Expand Down
4 changes: 0 additions & 4 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ variable "dns_subscription_id" {}
variable "dns_resource_group_name" {}
variable "dns_zone_name" {}

variable "log_analytics_subscription_id" {}
variable "log_analytics_resource_group_name" {}
variable "log_analytics_workspace_name" {}

variable "tags" {
default = {}
}
4 changes: 2 additions & 2 deletions terraform/web_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ resource "azurerm_linux_web_app" "app" {
app_settings = {
"minTlsVersion" = "1.2"
"READ_ONLY_MODE" = var.environment == "prd" ? "true" : "false"
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.ai.instrumentation_key
"APPLICATIONINSIGHTS_CONNECTION_STRING" = azurerm_application_insights.ai.connection_string
"APPINSIGHTS_INSTRUMENTATIONKEY" = data.azurerm_application_insights.core.instrumentation_key
"APPLICATIONINSIGHTS_CONNECTION_STRING" = data.azurerm_application_insights.core.connection_string
"ApplicationInsightsAgent_EXTENSION_VERSION" = "~3"
"ASPNETCORE_ENVIRONMENT" = var.environment == "prd" ? "Production" : "Development"
"WEBSITE_RUN_FROM_PACKAGE" = "1"
Expand Down

0 comments on commit 3607b98

Please sign in to comment.