Terraform Provider

The cachly/cachly Terraform provider lets you manage your entire cache infrastructure as code – instances, API keys, tiers, and more.

Installation

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

Provider Configuration

provider "cachly" {
  api_key  = var.cachly_api_key   # or CACHLY_API_KEY env var
  base_url = "https://cachly.dev" # default
}

The provider reads CACHLY_API_KEY from the environment if api_key is not set.

Resources

cachly_instance

Creates and manages a cache instance.

resource "cachly_instance" "prod" {
  name   = "production-cache"
  engine = "dragonfly"
  tier   = "pro"
  region = "eu-central"

  tags = {
    env = "production"
  }
}

cachly_api_key

Provisions an API key scoped to a specific instance.

resource "cachly_api_key" "app" {
  instance_id = cachly_instance.prod.id
  name        = "backend-key"
  scopes      = ["read", "write"]
}

Data Sources

cachly_instance (data source)

Look up an existing instance by name or ID.

data "cachly_instance" "existing" {
  name = "production-cache"
}

output "endpoint" {
  value = data.cachly_instance.existing.endpoint
}

Importing Existing Resources

terraform import cachly_instance.prod <instance-id>