@@ -425,6 +425,29 @@ jobs:
425425 exit 1
426426 fi
427427
428+ echo "✅ EKS cluster is active!"
429+
430+ # Check if node group exists (but don't fail if it doesn't)
431+ NODEGROUP_STATUS=$(aws eks describe-nodegroup \
432+ --cluster-name $EKS_CLUSTER_NAME \
433+ --nodegroup-name "$EKS_CLUSTER_NAME-node-group" \
434+ --region $AWS_REGION \
435+ --query 'nodegroup.status' \
436+ --output text 2>/dev/null || echo "NOT_FOUND")
437+
438+ if [ "$NODEGROUP_STATUS" = "NOT_FOUND" ]; then
439+ echo "⚠️ Node group not found - will be created in infrastructure step"
440+ elif [ "$NODEGROUP_STATUS" != "ACTIVE" ]; then
441+ echo "⚠️ Node group exists but not active (status: $NODEGROUP_STATUS)"
442+ else
443+ echo "✅ Node group is active!"
444+ fi
445+
446+ echo "✅ Infrastructure check completed - proceeding with deployment"
447+ - name : Create infrastructure if needed
448+ run : |
449+ echo "🔧 Checking if infrastructure needs to be created..."
450+
428451 # Check if node group exists
429452 NODEGROUP_STATUS=$(aws eks describe-nodegroup \
430453 --cluster-name $EKS_CLUSTER_NAME \
@@ -433,13 +456,44 @@ jobs:
433456 --query 'nodegroup.status' \
434457 --output text 2>/dev/null || echo "NOT_FOUND")
435458
436- if [ "$NODEGROUP_STATUS" != "ACTIVE" ]; then
437- echo "❌ Node group is not active (status: $NODEGROUP_STATUS)"
438- echo "🔧 Please ensure the infrastructure step runs successfully first"
439- exit 1
459+ if [ "$NODEGROUP_STATUS" = "NOT_FOUND" ]; then
460+ echo "🔧 Node group not found, creating infrastructure..."
461+
462+ # Use the existing Terraform setup
463+ echo "🔧 Using existing Terraform setup to create infrastructure..."
464+ echo "Please ensure the 'check-infra' job runs successfully to create the node group"
465+ echo "The node group will be created automatically by Terraform"
466+ else
467+ echo "✅ Infrastructure already exists"
440468 fi
441469
442- echo "✅ Infrastructure is ready!"
470+ # Wait for node group to be ready
471+ echo "⏳ Waiting for node group to be ready..."
472+ MAX_ATTEMPTS=20
473+ ATTEMPT=0
474+
475+ while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
476+ NODEGROUP_STATUS=$(aws eks describe-nodegroup \
477+ --cluster-name $EKS_CLUSTER_NAME \
478+ --nodegroup-name "$EKS_CLUSTER_NAME-node-group" \
479+ --region $AWS_REGION \
480+ --query 'nodegroup.status' \
481+ --output text 2>/dev/null || echo "NOT_FOUND")
482+
483+ echo "📊 Node group status: $NODEGROUP_STATUS (attempt $((ATTEMPT+1))/$MAX_ATTEMPTS)"
484+
485+ if [ "$NODEGROUP_STATUS" = "ACTIVE" ]; then
486+ echo "✅ Node group is active!"
487+ break
488+ fi
489+
490+ ATTEMPT=$((ATTEMPT+1))
491+ sleep 60
492+ done
493+
494+ if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
495+ echo "⚠️ Timeout waiting for node group to be ready, but continuing..."
496+ fi
443497 - name : Verify EKS cluster access
444498 run : |
445499 echo "Verifying access to EKS cluster: $EKS_CLUSTER_NAME"
0 commit comments