diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5acd98716d..74e51fd610 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,10 @@ { "name": "AzureTRE", + "features": { + "ghcr.io/devcontainers/features/sshd:1": { + "version": "latest" + } + }, "build": { "context": "..", "dockerfile": "Dockerfile", diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b34bcc442..b71c324a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/templates/shared_services/airlock_notifier/app/AirlockNotifier/workflow.json b/templates/shared_services/airlock_notifier/app/AirlockNotifier/workflow.json index 8cc8d4f585..13c65a9964 100644 --- a/templates/shared_services/airlock_notifier/app/AirlockNotifier/workflow.json +++ b/templates/shared_services/airlock_notifier/app/AirlockNotifier/workflow.json @@ -149,26 +149,25 @@ }, "Send_Email_with_SMTP": { "inputs": { - "body": { - "Body": "View the request", - "From": "@parameters('smtp_from_email')", - "Subject": "@variables('message')", - "To": "@{join(variables('recipients'), ';')}" - }, - "host": { - "connection": { - "referenceName": "smtp" - } + "parameters": { + "body": "View the request", + "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": { diff --git a/templates/shared_services/airlock_notifier/app/connections.json b/templates/shared_services/airlock_notifier/app/connections.json index 5d3e875838..56cd1dd9ad 100644 --- a/templates/shared_services/airlock_notifier/app/connections.json +++ b/templates/shared_services/airlock_notifier/app/connections.json @@ -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": { diff --git a/templates/shared_services/airlock_notifier/porter.yaml b/templates/shared_services/airlock_notifier/porter.yaml index 724ef79ade..c287b8677c 100644 --- a/templates/shared_services/airlock_notifier/porter.yaml +++ b/templates/shared_services/airlock_notifier/porter.yaml @@ -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 diff --git a/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf b/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf index 760a1e66f2..5e495a920d 100644 --- a/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf +++ b/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf @@ -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 @@ -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 @@ -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] } -} diff --git a/templates/shared_services/airlock_notifier/terraform/data.tf b/templates/shared_services/airlock_notifier/terraform/data.tf index 530bc63977..88d69fbf85 100644 --- a/templates/shared_services/airlock_notifier/terraform/data.tf +++ b/templates/shared_services/airlock_notifier/terraform/data.tf @@ -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" { } diff --git a/templates/shared_services/airlock_notifier/terraform/smtp-access-policy.json b/templates/shared_services/airlock_notifier/terraform/smtp-access-policy.json deleted file mode 100644 index 939e8679cd..0000000000 --- a/templates/shared_services/airlock_notifier/terraform/smtp-access-policy.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "servicePrincipalId": { - "type": "string" - }, - "servicePrincipalTenantId": { - "type": "string" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.Web/connections/accessPolicies", - "apiVersion": "2016-06-01", - "name": "[concat('smtp/', parameters('servicePrincipalId'))]", - "location": "[resourceGroup().location]", - "properties": { - "principal": { - "type": "ActiveDirectory", - "identity": { - "objectId": "[parameters('servicePrincipalId')]", - "tenantId": "[parameters('servicePrincipalTenantId')]" - } - } - } - } - ] -} diff --git a/templates/shared_services/airlock_notifier/terraform/smtp-api-connection.json b/templates/shared_services/airlock_notifier/terraform/smtp-api-connection.json deleted file mode 100644 index a236e0561f..0000000000 --- a/templates/shared_services/airlock_notifier/terraform/smtp-api-connection.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "serverAddress": { - "type": "string" - }, - "userName": { - "type": "string" - }, - "password": { - "type": "securestring" - }, - "serverPort": { - "type": "string" - }, - "enableSSL": { - "type": "bool" - } - }, - "variables": {}, - "resources": [ - { - "kind": "V2", - "properties": { - "displayName": "smtp", - "parameterValues": { - "serverAddress": "[parameters('serverAddress')]", - "userName": "[parameters('userName')]", - "password": "[parameters('password')]", - "port": "[parameters('serverPort')]", - "enableSSL": "[parameters('enableSSL')]" - }, - "api": { - "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'smtp')]" - } - }, - "name": "smtp", - "type": "Microsoft.Web/connections", - "location": "[resourceGroup().location]", - "apiVersion": "2016-06-01" - } - ], - "outputs": { - "connectionRuntimeUrl": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Web/connections', 'smtp'),'2016-06-01', 'full').properties.connectionRuntimeUrl]" - } - } -}