Skip to content

Commit 0beb3ef

Browse files
committed
feat: Resolve subnet ID dynamically for AKS deployment and add error handling
1 parent c852674 commit 0beb3ef

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/deploy-private-aks.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
timeout-minutes: 30
4646
outputs:
4747
mi_client_id: ${{ steps.identity.outputs.mi_client_id }}
48-
subnet_aks_id: ${{ steps.network.outputs.subnet_aks_id }}
4948

5049
steps:
5150
# ── 1a. Azure Login (OIDC from GitHub-hosted runner) ───────
@@ -319,11 +318,20 @@ jobs:
319318
- name: Deploy Private AKS Cluster
320319
id: deploy
321320
run: |
322-
SUBNET_AKS_ID="${{ needs.setup-runner.outputs.subnet_aks_id }}"
321+
SUBNET_AKS_ID=$(az network vnet subnet show \
322+
--resource-group "$INFRA_RG" \
323+
--vnet-name "$VNET_NAME" \
324+
--name "$SUBNET_AKS" \
325+
--query id -o tsv)
323326
324327
echo "Deploying private AKS cluster into subnet-aks..."
325328
echo " Subnet ID: $SUBNET_AKS_ID"
326329
330+
if [ -z "$SUBNET_AKS_ID" ]; then
331+
echo "::error::Failed to resolve subnet ID for $SUBNET_AKS in $VNET_NAME"
332+
exit 1
333+
fi
334+
327335
az aks create \
328336
--resource-group "$AKS_RG" \
329337
--name "$CLUSTER_NAME" \

0 commit comments

Comments
 (0)