Skip to content

byteBardShivansh/ai-workflow

Repository files navigation

🤖 AI Training Workflow

Simple GCP Infrastructure as Code for machine learning training workflows.

What Gets Created

  • VM (e2-medium) - AI/ML training compute instance
  • GCS bucket - dataset storage and results
  • Labels - resource organization and tracking

Quick Start

Prerequisites:

  • Terraform ~> 1.7
  • Google Cloud CLI
  • GCP project with billing

Setup:

gcloud auth login
gcloud config set project YOUR_PROJECT_ID

Run Workflow:

.\run-workflow.ps1 -DurationHours 2 -ProjectId your-gcp-project

Notes:

  • The launcher auto-sanitizes the owner label from your gcloud account (emails like user@example.com become user-example-com).
  • If running Terraform manually, ensure owner in terraform.tfvars matches GCP label rules: lowercase letters, digits, - or _, max 63 chars.

State storage:

  • Terraform state is stored remotely in GCS at gs://firefly-tfstate-backend/vm/default.tfstate.
  • The launcher ensures the bucket exists and migrates any local state automatically.

What Happens

  1. Deploy - VM + bucket created with proper labels
  2. Train - VM runs ML training workflow (~15 minutes)
  3. Monitor - Background monitoring for remainder of time
  4. Cleanup - Auto-destroy after workflow completion

Files

  • main.tf - Core infrastructure
  • variables.tf - Configuration options
  • outputs.tf - Resource info
  • startup-script.sh - AI training simulation
  • run-workflow.ps1 - One-command launcher

Cost

~$0.10 for 2-hour workflow (e2-medium + minimal storage)

Manual Operation

If you prefer manual control:

# 1. Setup
terraform init -reconfigure -migrate-state   # uses remote GCS backend
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your project_id (and optional labels). Ensure `owner` is label-compliant.

# 2. Deploy  
terraform plan
terraform apply

# 3. Wait for training completion (2 hours)

# 4. Cleanup
terraform destroy

Perfect for: ML experimentation, model training, automated workflows, cost-effective compute 🤖

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published