Skip to content

Terraform Provider

Manage CloudSlash configuration as infrastructure-as-code using the official Terraform provider.


Installation

The provider binary is built alongside the main CloudSlash binary. To install:

cd CloudSlash/
go build -o terraform-provider-cloudslash ./cmd/terraform-provider-cloudslash/
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/DrSkyle/cloudslash/1.0.0/darwin_arm64/
cp terraform-provider-cloudslash ~/.terraform.d/plugins/registry.terraform.io/DrSkyle/cloudslash/1.0.0/darwin_arm64/

Provider Configuration

terraform {
  required_providers {
    cloudslash = {
      source  = "DrSkyle/cloudslash"
      version = "~> 1.0"
    }
  }
}

provider "cloudslash" {
  daemon_url = "http://localhost:8080"   # Optional, defaults to localhost:8080
}

Example

Managing Plugins and Policies

# Activate the AWS and GCP plugins
resource "cloudslash_plugin" "aws" {
  name   = "aws"
  active = true
}

resource "cloudslash_plugin" "gcp" {
  name   = "gcp"
  active = true
}

# Define a cost guardrail policy
resource "cloudslash_policy" "cost_limit" {
  rule_id          = "block-expensive-resources"
  condition        = "cost > 500.0"
  action           = "block"
  message          = "Resources over $500/mo need VP approval"
  enforcement_mode = "enforcing"
  priority         = 100
}

# Define a tagging compliance policy
resource "cloudslash_policy" "require_env_tag" {
  rule_id          = "require-env-tag"
  condition        = "!('env' in tags)"
  action           = "warn"
  message          = "Missing env tag: SOC2 compliance requirement"
  enforcement_mode = "shadow"
  priority         = 90
}

Example

Daemon Configuration

resource "cloudslash_config" "daemon" {
  scan_interval         = "15m"
  alert_threshold_usd   = 5000
  slack_webhook         = var.slack_webhook_url
}

resource "cloudslash_config" "ai" {
  provider = "gemini"
  model    = "gemini-2.5-pro"
  # API key managed via CLOUDSLASH_AI_KEY environment variable
}

Use Cases

The Terraform provider is most useful when:

  • Team environments: Manage CloudSlash configuration consistently across multiple engineers via version-controlled HCL
  • GitOps workflows: Apply policy changes through the same PR pipeline as your infrastructure changes
  • Onboarding automation: Provision a fully-configured CloudSlash instance as part of a new environment setup
  • Compliance-as-code: Commit your SOC2/CIS policies to the repo alongside the infrastructure they govern

Provider maturity

The Terraform provider covers the most common configuration surfaces. Direct daemon API calls via curl or the Web Dashboard remain the primary interface for interactive management.