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

Logic app slack #8029

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b89f912
added api connections for workflow
shanice-skylight Aug 13, 2024
b224656
modified workflow action body text
shanice-skylight Aug 13, 2024
b0667f8
added id attribute to managed api reference
shanice-skylight Aug 13, 2024
9eac44e
added azapi resource to create managed api
shanice-skylight Aug 14, 2024
0e1332b
removed additional api connection
shanice-skylight Aug 14, 2024
a46a777
added a provider to pentest
shanice-skylight Aug 14, 2024
f4eea58
added provider to alert_app module
shanice-skylight Aug 14, 2024
3bc3b6c
provider.tf file content
shanice-skylight Aug 14, 2024
a36dc6f
fixed connection reference and removed resource azurerm_logic_app_api…
shanice-skylight Aug 14, 2024
2dea173
modified attribute being called
shanice-skylight Aug 14, 2024
2c140bd
modified resource azapi_resource type
shanice-skylight Aug 14, 2024
ac69376
turned off schema validation
shanice-skylight Aug 14, 2024
d71e2a3
modified reference to subscription
shanice-skylight Aug 14, 2024
456d0b1
modified api connection reference to managed api id
shanice-skylight Aug 14, 2024
0fde7d9
added new local variables to identify slack api and connection
shanice-skylight Aug 14, 2024
2e3dc25
added a key to the parameters
shanice-skylight Aug 14, 2024
40ac781
modified action body, connection parameter, and removed logic app cus…
shanice-skylight Aug 15, 2024
2c58a03
fixed parameter named connections
shanice-skylight Aug 15, 2024
48cd6e5
removed comments and resources no longer used, added logic app receiver
shanice-skylight Aug 15, 2024
8845026
modified the body of the alert and updated the channel alerts are sen…
shanice-skylight Aug 16, 2024
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
Prev Previous commit
Next Next commit
added azapi resource to create managed api
  • Loading branch information
shanice-skylight committed Aug 14, 2024
commit 9eac44e0d1d45508e253ad447158bc13837bdb01
20 changes: 19 additions & 1 deletion ops/services/alerts/alert_app/_var.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,23 @@ variable "global_vault" {
}

variable "channel" {
default = "Shanice Musiitwa (ATL, she/her)"
default = "Shanice Musiitwa (ATL, she/her)"
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"
default = "slack"
}

variable "logicAppName" {
default = "Slack-Integration-Workflow"

}
59 changes: 44 additions & 15 deletions ops/services/alerts/alert_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {

# Define the Logic App Workflow
resource "azurerm_logic_app_workflow" "slack_workflow" {
name = "alert-logic-app"
name = var.logicAppName
location = data.azurerm_resource_group.rg.location
#Create below api_connection
parameters = {
Expand Down Expand Up @@ -45,7 +45,7 @@ resource "azurerm_logic_app_action_custom" "res-3" {
inputs = {
host = {
connection = {
name = azurerm_api_connection.res-6.id
name = azurerm_api_connection.res-6.connection
}
}
method = "post"
Expand All @@ -69,49 +69,78 @@ resource "azurerm_logic_app_trigger_http_request" "res-4" {
name = "manual"
schema = jsonencode({
"$schema" = "http://json-schema.org/draft-04/schema#"
properties = {
context = {
properties = {
name = {
schemaId = {
data = {
essentials = {
alertId = {
type = "string"
}
portalLink = {
alertRule = {
type = "string"
}
resourceName = {
severity = {
type = "string"
}
}
required = ["name", "portalLink", "resourceName"]
required = ["alertId", "alertRule", "severity"]
type = "object"
}
status = {
type = "string"
}
}
required = ["status", "context"]
required = ["status", "data"]
type = "object"
})

}

resource "azurerm_logic_app_api_connection" "slack" {
name = var.slackConnectionName
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name

api {
id = "/subscriptions/${data.azurerm_subscription.primary.id}/providers/Microsoft.Web/locations/${data.azurerm_resource_group.rg_global.location}/managedApis/${var.connection_name}"
}

data "azurerm_managed_api" "data_api" {
name = "managed-api-1"
location = data.azurerm_resource_group.rg.location
display_name = "slack"
}


resource "azapi_resource" "createApiConnectionslack" {
type = "Microsoft.Web/connections@2018-06-07-01"
name = var.connection_name
parent_id = data.azurerm_resource_group.rg.id
location = data.azurerm_resource_group.rg.location


body = jsonencode({
properties = {

api = {
name = var.connection_name
displayName = "slack"
description = "Slack is a team communication tool, that brings together all of your team communications in one place, instantly searchable and available wherever you go."
iconUri = "https://connectoricons-prod.azureedge.net/releases/v1.0.1669/1.0.1669.3522/slack/icon.png"
brandColor = "#78D4B6"
id = "/subscriptions/${data.azurerm_subscription.primary.id}/providers/Microsoft.Web/locations/${data.azurerm_resource_group.rg_global.location}/managedApis/${var.connection_name}"
type = "Microsoft.Web/locations/managedApis"
}
}
})
}



resource "azurerm_api_connection" "api_connection_1" {
managed_api_id = data.azurerm_managed_api.data_api.id
managed_api_id = azapi_resource.createApiConnectionslack.id
name = "SlackConnection"
resource_group_name = data.azurerm_resource_group.rg.name
}

resource "azurerm_api_connection" "res-6" {
managed_api_id = data.azurerm_managed_api.data_api.id
managed_api_id = azapi_resource.createApiConnectionslack.id
name = "slack-1"
resource_group_name = data.azurerm_resource_group.rg.name
}
Expand Down
Loading