Overview

Terraform Provider

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 isn't 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>

See Cache Engines for the engine values this provider accepts, and Cluster Mode for the cluster block on cachly_instance.

← Back to all docs

Updated

Was this page helpful?