Skip to content

Commit

Permalink
removed comments and resources no longer used, added logic app receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
shanice-skylight committed Aug 15, 2024
1 parent 2c58a03 commit 48cd6e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 48 deletions.
7 changes: 1 addition & 6 deletions ops/services/alerts/alert_app/_var.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ variable "channel" {
description = "The Slack channel to post to."
}

variable "slackConnectionName" {
type = string
default = "SlackConnection"
description = "The name for the Slack connection."
}

variable "connection_name" {
type = string
description = "This connection must be manually activated in the Azure Console after deployment"
description = "This connection must be manually activated in the Azure Console after deployment to test other will have to wait for Alert Group to trigger it"
default = "slack"
}

Expand Down
47 changes: 5 additions & 42 deletions ops/services/alerts/alert_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ locals {
prime-app = "simple-report"
resource_group = data.azurerm_resource_group.rg.name
}
slack_api_id = "${data.azurerm_subscription.primary.id}/resourceGroups/${data.azurerm_resource_group.rg.name}/providers/Microsoft.Web/locations/${data.azurerm_resource_group.rg_global.location}/managedApis/slack"
slack_connection_id = "${data.azurerm_subscription.primary.id}/resourceGroups/${data.azurerm_resource_group.rg.name}/providers/Microsoft.Web/connections/${var.slackConnectionName}"

}


Expand Down Expand Up @@ -41,31 +38,7 @@ resource "azurerm_logic_app_action_http" "workflow_action" {
}
}

#
# resource "azurerm_logic_app_action_custom" "res-3" {
# body = jsonencode({
# inputs = {
# host = {
# connection = {
# name = "@parameters('$connections')['slack']['connectionId']"
# }
#
# }
# method = "post"
# path = "/chat.postMessage"
# queries = {
# channel = var.channel
# text = "Azure Alert - '@{triggerBody()['context']['name']}' @{triggerBody()['status']} on '@{triggerBody()['context']['resourceName']}'. Details: @{body('Http')['id']}"
# }
# }
# runAfter = {
# Http = ["Succeeded"]
# }
# type = "ApiConnection"
# })
# logic_app_id = azurerm_logic_app_workflow.slack_workflow.id
# name = "Post_Message"
# }


resource "azurerm_logic_app_trigger_http_request" "res-4" {
logic_app_id = azurerm_logic_app_workflow.slack_workflow.id
Expand Down Expand Up @@ -246,25 +219,15 @@ resource "azapi_resource" "createApiConnectionslack" {



resource "azurerm_api_connection" "api_connection_1" {
managed_api_id = "${data.azurerm_subscription.primary.id}/providers/Microsoft.Web/locations/${data.azurerm_resource_group.rg_global.location}/managedApis/${var.connection_name}"
name = "SlackConnection"
resource_group_name = data.azurerm_resource_group.rg.name
}






resource "azurerm_monitor_action_group" "on_call_action_group" {
name = "OnCallEngineer"
resource_group_name = data.azurerm_resource_group.rg.name
short_name = "OnCall"
webhook_receiver {
name = "logicappaction"
service_uri = data.azurerm_key_vault_secret.azure_alert_slack_webhook.value
logic_app_receiver {
name = var.logicAppName
resource_id = azurerm_logic_app_workflow.slack_workflow.id
callback_url = azurerm_logic_app_workflow.slack_workflow.access_endpoint
use_common_alert_schema = false
}
}

0 comments on commit 48cd6e5

Please sign in to comment.