Skip to content

Commit

Permalink
Merge pull request #275 from danskernesdigitalebibliotek/provision-ma…
Browse files Browse the repository at this point in the history
…il-services

Provision mail services
  • Loading branch information
ITViking authored Apr 30, 2024
2 parents 020ef89 + 61de60a commit 32c67d8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
26 changes: 25 additions & 1 deletion infrastructure/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,12 @@ tasks:
sh: source "{{.dir_lagoon}}/lagoon-versions.env" && echo $VERSION_LAGOON_REMOTE
BUILD_DEPLOY_DIND_IMAGE_VER:
sh: source "{{.dir_lagoon}}/lagoon-versions.env" && echo $BUILD_DEPLOY_DIND_IMAGE_VER
ACS_CONNECTION_STRING:
sh: terraform -chdir={{.dir_infra}} output -json | jq --raw-output ".acs_connection_string.value | select (.!=null)"
cmds:
# Render the variables we've collected into a values file we can install.
- |
envsubst '$SSH_LOADBALANCER_IP $RABBITMQ_PASS $HARBOR_ADMIN_PASS $SQL_HOSTNAME $SQL_SERVERNAME $SQL_USER $SQL_PASSWORD $BUILD_DEPLOY_DIND_IMAGE_VER' \
envsubst '$SSH_LOADBALANCER_IP $RABBITMQ_PASS $HARBOR_ADMIN_PASS $SQL_HOSTNAME $SQL_SERVERNAME $SQL_USER $SQL_PASSWORD $BUILD_DEPLOY_DIND_IMAGE_VER $ACS_CONNECTION_STRING' \
< "{{.dir_lagoon}}/lagoon-remote-values.template.yaml" \
> "{{.dir_lagoon}}/lagoon-remote-values.yaml"
# Setup the namespace manually to control eg. labels on the namespace.
Expand Down Expand Up @@ -585,6 +587,28 @@ tasks:
- sh: "[ ! -z \"{{.PROJECT_NAME}}\" ]"
msg: "Missing PROJECT_ID or PROJECT_NAME - at least one must be set"

lagoon:project:ensure:azure-mail-connection-string:
vars:
ACS_CONNECTION_STRING:
sh: az communication list-key
--name communication-servicesa5e3
--resource-group
$(
terraform -chdir={{.dir_infra}} output -json | jq --raw-output ".resourcegroup_name.value | select (.!=null)"
)
--query "primaryConnectionString"
--output tsv
cmds:
- task: lagoon:ensure:environment-variable
vars:
VARIABLE_SCOPE: "CONTAINER_REGISTRY"
VARIABLE_NAME: "AZURE_MAIL_CONNECTION_STRING"
VARIABLE_VALUE: "{{.ACS_CONNECTION_STRING}}"
PROJECT_NAME: "{{.PROJECT_NAME}}"
preconditions:
- sh: "[ ! -z \"{{.PROJECT_NAME}}\" ]"
msg: "Missing PROJECT_ID or PROJECT_NAME - at least one must be set"

lagoon:add:cluster:
deps: [cluster:auth]
desc: Add a Kubernetes cluster (Lagoon Remote) to the Lagoon Core.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# resource "azurerm_key_vault_secret" "azurerm_communication_service_connection_string" {
# name = "azurerm-communication-service-connection-string"
# value = azurerm_communication_service.acs.primary_connection_string
# key_vault_id = azurerm_key_vault.keyvault.id
# }
provider "azurerm" {
features {}
}

resource "random_id" "acs" {
byte_length = 2
}

resource "azurerm_communication_service" "communications-services" {
name = "communication-services${random_id.acs.hex}"
resource_group_name = azurerm_resource_group.rg.name
data_location = "Germany"
}

resource "azurerm_email_communication_service" "email-service" {
name = "email-service${random_id.acs.hex}"
resource_group_name = azurerm_resource_group.rg.name
data_location = "Germany"
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,9 @@ output "harbor_secondary_access_key_name" {
description = "Name under which the secondary harbor storage account key is stored in keyvault"
value = azurerm_key_vault_secret.harbor_secondary_access_key.name
}

output "acs_connection_string" {
description = "The conneciton string for Azure Communication Service"
value = azurerm_communication_service.communications-services.primary_connection_string
sensitive = true
}

0 comments on commit 32c67d8

Please sign in to comment.