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

Certs shared service: Secret nexus-ssl-password is currently in a deleted but recoverable state #4295

Merged
merged 15 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ENHANCEMENTS:

BUG FIXES:
* Fix upgrade when porter install has failed ([#4338](https://github.com/microsoft/AzureTRE/pull/4338))
* Certs shared service: Secret nexus-ssl-password is currently in a deleted but recoverable state ([#4294](https://github.com/microsoft/AzureTRE/issues/4294)])
* Fix Cosmos DB local debugging configuration ([#4340](https://github.com/microsoft/AzureTRE/pull/4340))


COMPONENTS:

## 0.20.0 (Feburary 9, 2025)
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.3
version: 0.7.4
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
15 changes: 15 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,18 @@ 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
tags = local.tre_shared_service_tags

# 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
}
Loading