Skip to content

Commit f87966c

Browse files
rajbosCopilot
andcommitted
fix: re-register hostname and cert binding after container app updates
When Terraform modifies azurerm_container_app (e.g. adding ADMIN_GITHUB_LOGINS), the Azure provider sends the full ingress config without custom hostnames, wiping any previously-registered hostname. The null_resource.hostname_registration was not re-triggered because its triggers (hostname + app_id) are stable across modifications — only creation changes the ID. Add `replace_triggered_by = [azurerm_container_app.this]` to both null_resource.hostname_registration and null_resource.cert_binding so they re-run on every container app update, ensuring: 1. The custom hostname is re-registered (required before cert can be issued) 2. The SniEnabled cert binding is re-applied (required for HTTPS to work) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9911e4c commit f87966c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sharing-server/infra/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ resource "null_resource" "hostname_registration" {
208208
app_id = azurerm_container_app.this.id
209209
}
210210

211+
# Re-run whenever the container app is modified, because ACA updates reset
212+
# the ingress configuration and strip any previously-registered custom hostnames.
213+
lifecycle {
214+
replace_triggered_by = [azurerm_container_app.this]
215+
}
216+
211217
provisioner "local-exec" {
212218
command = "az containerapp hostname add --name '${azurerm_container_app.this.name}' --resource-group '${var.resource_group_name}' --hostname '${var.custom_domain}' 2>/dev/null || true"
213219
}
@@ -242,6 +248,12 @@ resource "null_resource" "cert_binding" {
242248
hostname = var.custom_domain
243249
}
244250

251+
# Re-run whenever the container app is modified, because ACA updates reset
252+
# the ingress configuration and strip any previously-applied cert bindings.
253+
lifecycle {
254+
replace_triggered_by = [azurerm_container_app.this]
255+
}
256+
245257
provisioner "local-exec" {
246258
environment = {
247259
CERT_ID = azurerm_container_app_environment_managed_certificate.this[0].id

0 commit comments

Comments
 (0)