Skip to content

Commit

Permalink
Certs shared service: Secret nexus-ssl-password is currently in a del…
Browse files Browse the repository at this point in the history
…eted but recoverable state #4294
  • Loading branch information
jonnyry committed Feb 1, 2025
1 parent 7c88fe4 commit 739ba8b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ BUG FIXES:
* Fix VM actions where Workspace shared storage doesn't allow shared key access ([#4222](https://github.com/microsoft/AzureTRE/issues/4222))
* Fix public exposure in Guacamole service ([[#4199](https://github.com/microsoft/AzureTRE/issues/4199)])
* Fix Azure ML network tags to use name rather than ID ([[#4151](https://github.com/microsoft/AzureTRE/issues/4151)])
* Certs shared service: Secret nexus-ssl-password is currently in a deleted but recoverable state ([#4294](https://github.com/microsoft/AzureTRE/issues/4294)])

COMPONENTS:

Expand Down
6 changes: 5 additions & 1 deletion templates/shared_services/certs/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-shared-service-certs
version: 0.7.2
version: 0.7.3
description: "An Azure TRE shared service to generate certificates for a specified internal domain using Letsencrypt"
registry: azuretre
dockerfile: Dockerfile.tmpl
Expand Down Expand Up @@ -88,6 +88,7 @@ install:
- name: storage_account_name
- name: resource_group_name
- name: keyvault_name
- name: password_name
- az:
description: "Set Azure Cloud Environment"
arguments:
Expand All @@ -114,6 +115,7 @@ install:
resource_group_name: ${ bundle.outputs.resource_group_name }
keyvault_name: ${ bundle.outputs.keyvault_name }
cert_name: ${ bundle.parameters.cert_name }
password_name: ${ bundle.outputs.password_name }
- az:
description: "Stop application gateway"
arguments:
Expand Down Expand Up @@ -167,6 +169,7 @@ renew:
- name: storage_account_name
- name: resource_group_name
- name: keyvault_name
- name: password_name
- az:
description: "Set Azure Cloud Environment"
arguments:
Expand Down Expand Up @@ -202,6 +205,7 @@ renew:
resource_group_name: ${ bundle.outputs.resource_group_name }
keyvault_name: ${ bundle.outputs.keyvault_name }
cert_name: ${ bundle.parameters.cert_name }
password_name: ${ bundle.outputs.password_name }
- az:
description: "Stop application gateway"
arguments:
Expand Down
8 changes: 6 additions & 2 deletions templates/shared_services/certs/scripts/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ while [ "$1" != "" ]; do
shift
cert_name=$1
;;
--password_name)
shift
password_name=$1
;;
*)
echo "Unexpected argument: '$1'"
usage
Expand Down Expand Up @@ -122,8 +126,8 @@ sid=$(az keyvault certificate import \
--password "${CERT_PASSWORD}" \
| jq -r '.sid')

echo "Saving certificate password to KV with key ${cert_name}-password"
az keyvault secret set --name "${cert_name}"-password \
echo "Saving certificate password to KV with key ${password_name}"
az keyvault secret set --name "$password_name" \
--vault-name "${keyvault_name}" \
--value "${CERT_PASSWORD}"

Expand Down
14 changes: 14 additions & 0 deletions templates/shared_services/certs/terraform/certificate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ resource "azurerm_key_vault_certificate" "tlscert" {
}

}

# pre-create in advance of the real password being created
# so if there is a deleted secret it will be recovered
#
resource "azurerm_key_vault_secret" "cert_password" {
name = local.password_name
value = "0000000000"
key_vault_id = data.azurerm_key_vault.key_vault.id

# The password will get replaced with a real one, so we don't want Terraform to try and revert it.
lifecycle {
ignore_changes = all
}
}
1 change: 1 addition & 0 deletions templates/shared_services/certs/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ locals {

cmk_name = "tre-encryption-${var.tre_id}"
encryption_identity_name = "id-encryption-${var.tre_id}"
password_name = "${var.cert_name}-password"
}
4 changes: 4 additions & 0 deletions templates/shared_services/certs/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ output "resource_group_name" {
output "keyvault_name" {
value = data.azurerm_key_vault.key_vault.name
}

output "password_name" {
value = local.password_name
}

0 comments on commit 739ba8b

Please sign in to comment.