diff --git a/.env.terraform.sh.example b/.env.terraform.sh.example deleted file mode 100644 index fe76baa..0000000 --- a/.env.terraform.sh.example +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Terraform environment setup example -# Copy to .env.terraform.sh and fill in real values from .env -# Then: source .env.terraform.sh && cd terraform && terraform plan - -# MinIO S3 backend credentials (from .env MINIO_ROOT_USER / MINIO_ROOT_PASSWORD) -export AWS_ACCESS_KEY_ID="minioadmin" -export AWS_SECRET_ACCESS_KEY="" - -# Kubernetes config (points to cluster-config/kubeconfig) -export KUBECONFIG="${PWD}/cluster-config/kubeconfig" diff --git a/scripts/terraform-state-backup.sh b/scripts/terraform-state-backup.sh deleted file mode 100755 index 26fcbaf..0000000 --- a/scripts/terraform-state-backup.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# Terraform state backup script -# Backs up Terraform state to local directory and verifies S3 backend accessibility - -set -e - -BACKUP_DIR="$HOME/.terraform-backups/homelab" -TIMESTAMP=$(date +%Y%m%d-%H%M%S) -STATE_BACKUP="$BACKUP_DIR/$TIMESTAMP-terraform.tfstate" - -mkdir -p "$BACKUP_DIR" - -echo "=== Terraform State Backup ===" -echo "Backup directory: $BACKUP_DIR" - -# Navigate to terraform directory -cd "$(dirname "${BASH_SOURCE[0]}")/../terraform" || exit 1 - -# Pull state from remote backend -echo "Pulling Terraform state from S3..." -terraform state pull > "$STATE_BACKUP" && \ - echo "✓ State backed up to $STATE_BACKUP" || \ - echo "⚠️ Failed to pull state (S3 backend may not be initialized)" - -# Verify S3 bucket -echo "" -echo "Verifying S3 backend accessibility..." -if [ -z "$KUBECONFIG" ]; then - echo "⚠️ KUBECONFIG not set. Run: core auth login" - exit 1 -fi - -if kubectl get pods -n storage -l app=minio &>/dev/null; then - MINIO_POD=$(kubectl get pods -n storage -l app=minio -o jsonpath='{.items[0].metadata.name}') - echo "MinIO pod: $MINIO_POD" - - # Check bucket - if kubectl exec -n storage "$MINIO_POD" -- mc ls minio/terraform-state &>/dev/null; then - echo "✓ S3 bucket 'terraform-state' accessible" - else - echo "⚠️ S3 bucket 'terraform-state' not found or inaccessible" - echo " To create: kubectl exec -n storage $MINIO_POD -- mc mb minio/terraform-state" - fi -else - echo "⚠️ MinIO not running in storage namespace" -fi - -# Keep only last 30 backups -echo "" -echo "Cleaning up old backups (keeping last 30)..." -ls -t "$BACKUP_DIR"/*.tfstate 2>/dev/null | tail -n +31 | xargs -r rm && \ - echo "✓ Cleanup complete" || \ - echo "ℹ️ No old backups to remove" - -echo "" -echo "Backup complete. Location: $STATE_BACKUP"