Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Mar 29, 2024
1 parent 45bf64c commit 14b67e7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 200 deletions.
50 changes: 50 additions & 0 deletions scripts/terraform_scripts/activate_tf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Script to apply Terraform configuration with enhanced logging and error handling
# Define the directory where your Terraform scripts are located
TERRAFORM_DIR="/swarms-cloud/scripts/terraform_scripts/multi_cloud_consul/main.tf"

# Define the log file path
LOG_FILE="/var/log/terraform_apply.log"

# Function to log messages with timestamps
log() {
echo "[$(date +"%Y-%m-%d %T")] $1" >> "$LOG_FILE"
}

# Ensure the Terraform directory exists
if [ ! -d "$TERRAFORM_DIR" ]; then
log "The specified Terraform directory does not exist: $TERRAFORM_DIR"
exit 1
fi

# Navigate to the Terraform directory
cd "$TERRAFORM_DIR" || exit

# Begin Terraform process
log "Starting Terraform apply..."

# Initialize Terraform
terraform init >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
log "Terraform init failed."
exit 1
else
log "Terraform init succeeded."
fi

# Apply Terraform configuration
terraform apply -auto-approve >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
log "Terraform apply failed."
exit 1
else
log "Terraform apply succeeded."
fi

log "Terraform apply completed successfully."

# Add cron job if it doesn't exist
CRON_JOB="0 3 * * * /path/to/terraform_apply.sh"
( crontab -l | grep -Fv terraform_apply.sh ; echo "$CRON_JOB" ) | crontab -
log "Cron job for Terraform apply script ensured."
200 changes: 0 additions & 200 deletions swarms_cloud/sky_api.py

This file was deleted.

0 comments on commit 14b67e7

Please sign in to comment.