Skip to content

Commit

Permalink
Airlock Notifier - Change SMTP connector type (#3573)
Browse files Browse the repository at this point in the history
* Airlock Notifier - Change SMTP connector type

* Update CHANGELOG.md
  • Loading branch information
SharonHart authored Jun 15, 2023
1 parent 63bc06b commit 0ed36d0
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 157 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"name": "AzureTRE",
"features": {
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
}
},
"build": {
"context": "..",
"dockerfile": "Dockerfile",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FEATURES:

ENHANCEMENTS:
* Workspace networking peering sync is handled natively by Terraform ([#3534](https://github.com/microsoft/AzureTRE/issues/3534))
* Use SMTP built in connector vs API connector in Airlock Notifier ([#3572](https://github.com/microsoft/AzureTRE/issues/3572))

BUG FIXES:
* Nexus might fail to deploy due to wrong identity used in key-vault extension ([#3492](https://github.com/microsoft/AzureTRE/issues/3492))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,25 @@
},
"Send_Email_with_SMTP": {
"inputs": {
"body": {
"Body": "<a href=\"@{parameters('tre_url')}/workspaces/@{body('Parse_JSON')?['data']?['workspace']?['id']}/requests/@{body('Parse_JSON')?['data']?['request']?['id']}\">View the request</a>",
"From": "@parameters('smtp_from_email')",
"Subject": "@variables('message')",
"To": "@{join(variables('recipients'), ';')}"
},
"host": {
"connection": {
"referenceName": "smtp"
}
"parameters": {
"body": "<a href=\"@{parameters('tre_url')}/workspaces/@{body('Parse_JSON')?['data']?['workspace']?['id']}/requests/@{body('Parse_JSON')?['data']?['request']?['id']}\">View the request</a>",
"from": "@parameters('smtp_from_email')",
"importance": "Normal",
"subject": "@variables('message')",
"to": "@{join(variables('recipients'), ';')}"
},
"method": "post",
"path": "/SendEmailV3"
"serviceProviderConfiguration": {
"connectionName": "Smtp",
"operationId": "sendEmail",
"serviceProviderId": "/serviceProviders/Smtp"
}
},
"runAfter": {
"Switch_on_request_status": [
"Succeeded"
]
},
"type": "ApiConnection"
"type": "ServiceProvider"
},
"Succeeded": {
"inputs": {
Expand Down
13 changes: 13 additions & 0 deletions templates/shared_services/airlock_notifier/app/connections.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
"id": "/serviceProviders/serviceBus"
},
"displayName": "core-service-bus"
},
"Smtp": {
"displayName": "smtp",
"parameterValues": {
"enableSSL": "@appsetting('smtp_server_enable_ssl')",
"port": "@appsetting('smtp_server_port')",
"password": "@appsetting('smtp_password')",
"serverAddress": "@appsetting('smtp_server_address')",
"username": "@appsetting('smtp_username')"
},
"serviceProvider": {
"id": "/serviceProviders/Smtp"
}
}
},
"managedApiConnections": {
Expand Down
2 changes: 1 addition & 1 deletion templates/shared_services/airlock_notifier/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-shared-service-airlock-notifier
version: 0.8.0
version: 0.9.0
description: "A shared service notifying on Airlock Operations"
registry: azuretre
dockerfile: Dockerfile.tmpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,6 @@ resource "azurerm_eventgrid_event_subscription" "airlock_notification" {
}
}

// Using ARM as terraform's azurerm_api_connection creates a v1 api connection,
// without connectionRuntimeUrl needed for SMTP https://github.com/hashicorp/terraform-provider-azurerm/issues/16195
resource "azurerm_resource_group_template_deployment" "smtp_api_connection" {
name = "smtp-api-connection"
resource_group_name = data.azurerm_resource_group.core.name

template_content = data.local_file.smtp_api_connection.content


parameters_content = jsonencode({
"serverAddress" = {
value = var.smtp_server_address
},
"userName" = {
value = var.smtp_username
},
"password" = {
value = var.smtp_password
},
"enableSSL" = {
value = var.smtp_server_enable_ssl
},
"serverPort" = {
value = var.smtp_server_port
}
})

deployment_mode = "Incremental"
tags = local.tre_shared_service_tags
lifecycle { ignore_changes = [tags] }
}

resource "azurerm_logic_app_standard" "logic_app" {
name = "airlock-notifier-app-${var.tre_id}"
location = data.azurerm_resource_group.core.location
Expand All @@ -74,7 +42,11 @@ resource "azurerm_logic_app_standard" "logic_app" {
"serviceBus_connectionString" = data.azurerm_servicebus_namespace.core.default_primary_connection_string
"subscription" = data.azurerm_subscription.current.subscription_id
"resource_group" = data.azurerm_resource_group.core.name
"smtp_connection_runtime_url" = jsondecode(azurerm_resource_group_template_deployment.smtp_api_connection.output_content).connectionRuntimeUrl.value
"smtp_server_address" = var.smtp_server_address
"smtp_server_port" = var.smtp_server_port
"smtp_server_enable_ssl" = var.smtp_server_enable_ssl
"smtp_username" = var.smtp_username
"smtp_password" = var.smtp_password
"smtp_from_email" = var.smtp_from_email
"tre_url" = var.tre_url != "" ? var.tre_url : local.default_tre_url
"APPLICATIONINSIGHTS_CONNECTION_STRING" = data.azurerm_application_insights.core.connection_string
Expand All @@ -90,25 +62,3 @@ resource "azurerm_logic_app_standard" "logic_app" {
tags = local.tre_shared_service_tags
lifecycle { ignore_changes = [tags] }
}


resource "azurerm_resource_group_template_deployment" "smtp_api_connection_access_policy" {
name = "smtp-api-connection-access-policy"
resource_group_name = data.azurerm_resource_group.core.name

template_content = data.local_file.smtp_access_policy.content


parameters_content = jsonencode({
"servicePrincipalId" = {
value = azurerm_logic_app_standard.logic_app.identity[0].principal_id
},
"servicePrincipalTenantId" = {
value = azurerm_logic_app_standard.logic_app.identity[0].tenant_id
}
})

deployment_mode = "Incremental"
tags = local.tre_shared_service_tags
lifecycle { ignore_changes = [tags] }
}
8 changes: 0 additions & 8 deletions templates/shared_services/airlock_notifier/terraform/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ data "azurerm_resource_group" "core" {
name = local.core_resource_group_name
}

data "local_file" "smtp_api_connection" {
filename = "${path.module}/smtp-api-connection.json"
}

data "local_file" "smtp_access_policy" {
filename = "${path.module}/smtp-access-policy.json"
}

data "azurerm_subscription" "current" {
}

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 0ed36d0

Please sign in to comment.