73 lines
2.3 KiB
Bash
73 lines
2.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Script to get Qdrant VM IP address from Terraform outputs
|
|
# Usage: ./get_qdrant_ip.sh [--internal]
|
|
|
|
set -e
|
|
|
|
# Change to terraform directory
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# Check if terraform state exists
|
|
if [ ! -f "terraform.tfstate" ]; then
|
|
echo "ERROR: No terraform.tfstate found. Please run 'terraform apply' first."
|
|
exit 1
|
|
fi
|
|
|
|
# Parse command line arguments
|
|
INTERNAL=false
|
|
if [ "$1" = "--internal" ]; then
|
|
INTERNAL=true
|
|
fi
|
|
|
|
echo "Retrieving Qdrant VM IP address..."
|
|
echo "=================================="
|
|
|
|
# Get VM information
|
|
VM_NAME=$(terraform output -raw vector_db_vm_name 2>/dev/null || echo "N/A")
|
|
echo "VM Name: $VM_NAME"
|
|
|
|
if [ "$INTERNAL" = true ]; then
|
|
# Get internal IP
|
|
QDRANT_IP=$(terraform output -raw vector_db_vm_internal_ip 2>/dev/null || echo "N/A")
|
|
echo "Internal IP: $QDRANT_IP"
|
|
echo "Qdrant HTTP Endpoint (Internal): http://$QDRANT_IP:6333"
|
|
echo "Qdrant gRPC Endpoint (Internal): http://$QDRANT_IP:6334"
|
|
else
|
|
# Get external IP
|
|
QDRANT_IP=$(terraform output -raw vector_db_vm_external_ip 2>/dev/null || echo "N/A")
|
|
echo "External IP: $QDRANT_IP"
|
|
echo "Qdrant HTTP Endpoint: http://$QDRANT_IP:6333"
|
|
echo "Qdrant gRPC Endpoint: http://$QDRANT_IP:6334"
|
|
fi
|
|
|
|
# Check if static IP is enabled
|
|
STATIC_IP_ENABLED=$(terraform output -raw vector_db_static_ip 2>/dev/null || echo "null")
|
|
if [ "$STATIC_IP_ENABLED" != "null" ] && [ "$STATIC_IP_ENABLED" != "" ]; then
|
|
echo "Static IP: $STATIC_IP_ENABLED (enabled)"
|
|
else
|
|
echo "Static IP: Not enabled (using ephemeral IP)"
|
|
fi
|
|
|
|
# Get Cloud Run service URL
|
|
CLOUD_RUN_URL=$(terraform output -raw cloud_run_url 2>/dev/null || echo "N/A")
|
|
echo "Cloud Run URL: $CLOUD_RUN_URL"
|
|
|
|
echo ""
|
|
echo "Environment Variables for Cloud Run:"
|
|
echo "QDRANT_HOST=$QDRANT_IP"
|
|
echo "QDRANT_PORT=6333"
|
|
|
|
# Test connectivity (optional)
|
|
echo ""
|
|
echo "Testing Qdrant connectivity..."
|
|
if command -v curl &> /dev/null; then
|
|
if curl -s --connect-timeout 5 "http://$QDRANT_IP:6333/health" > /dev/null; then
|
|
echo "✓ Qdrant is accessible at http://$QDRANT_IP:6333"
|
|
else
|
|
echo "✗ Qdrant is not accessible at http://$QDRANT_IP:6333"
|
|
echo " This might be normal if the VM is still starting up or firewall rules need adjustment."
|
|
fi
|
|
else
|
|
echo "curl not available - skipping connectivity test"
|
|
fi |