@@ -756,39 +756,22 @@ resource "null_resource" "hub_pki_principal_server_cert_updated" {
756756 set -o pipefail
757757
758758 LOG_FILE="/tmp/argocd-pki-principal-cert-update-$$(date +%Y%m%d-%H%M%S).log"
759- PRINCIPAL_ADDRESS="${ data . external . hub_principal_address . result . address } "
760- EXPOSE_METHOD="${ var . principal_expose_method } "
759+ PRINCIPAL_IP="${ data . external . hub_principal_address . result . address } "
761760
762761 echo "Updating Principal certificate with external address..." | tee -a "$LOG_FILE"
763- echo "Exposure method: $EXPOSE_METHOD" | tee -a "$LOG_FILE"
764- echo "Principal address: $PRINCIPAL_ADDRESS" | tee -a "$LOG_FILE"
762+ echo "Principal address: $PRINCIPAL_IP" | tee -a "$LOG_FILE"
765763
766- # For ingress mode, address should be a hostname
767- # For loadbalancer/nodeport, address should be an IP
768- if [ "$PRINCIPAL_ADDRESS" = "pending" ] || [ "$PRINCIPAL_ADDRESS" = "error" ]; then
769- echo "✗ ERROR: Principal address not ready yet" | tee -a "$LOG_FILE"
764+ if [ "$PRINCIPAL_IP" = "pending" ] || [ "$PRINCIPAL_IP" = "error" ]; then
765+ echo "✗ ERROR: Cannot update certificate - LoadBalancer not ready" | tee -a "$LOG_FILE"
770766 exit 1
771767 fi
772768
773- # Build certificate parameters based on exposure method
774- if [ "$EXPOSE_METHOD" = "ingress" ]; then
775- # Ingress: add hostname to DNS field
776- CERT_IP="127.0.0.1"
777- CERT_DNS="localhost,${ local . principal_dns } ,$PRINCIPAL_ADDRESS"
778- echo "Ingress mode: Using DNS=$CERT_DNS" | tee -a "$LOG_FILE"
779- else
780- # LoadBalancer/NodePort: add IP to IP field
781- CERT_IP="127.0.0.1,$PRINCIPAL_ADDRESS"
782- CERT_DNS="${ local . principal_dns } "
783- echo "LoadBalancer/NodePort mode: Using IP=$CERT_IP, DNS=$CERT_DNS" | tee -a "$LOG_FILE"
784- fi
785-
786769 echo "Issuing updated Principal server certificate..." | tee -a "$LOG_FILE"
787770 if ! ${ var . argocd_agentctl_path } pki issue principal \
788771 --principal-context ${ var . hub_cluster_context } \
789772 --principal-namespace ${ var . hub_namespace } \
790- --ip "$CERT_IP " \
791- --dns "$CERT_DNS " \
773+ --ip "127.0.0.1,$PRINCIPAL_IP " \
774+ --dns "${ local . principal_dns } " \
792775 --upsert 2>&1 | tee -a "$LOG_FILE"; then
793776 echo "✗ ERROR: Failed to update Principal certificate. Check logs: $LOG_FILE" | tee -a "$LOG_FILE"
794777 exit 1
0 commit comments