Terraform Provider
Overview
The Dragonfly Cloud Terraform Provider allows you to manage your Dragonfly Cloud resources using infrastructure as code. This provider is currently in beta and enables you to automate the provisioning and management of your Dragonfly Cloud infrastructure. The provider is available on both the Terraform Registry and OpenTofu Registry.
Usage
To use the provider in your Terraform configuration, include the following provider block:
terraform {
required_providers {
dfcloud = {
source = "registry.terraform.io/dragonflydb/dfcloud"
}
}
}
provider "dfcloud" {
api_key = "<YOUR_API_KEY>"
}
Authentication
The provider requires an API token for authentication. You can provide this token in one of two ways:
- Environment variable:
export DFCLOUD_API_KEY="your_api_token"
- Provider configuration (as shown in the example above)
Available Resources
The Dragonfly Cloud Terraform provider allows you to manage various resources in your Dragonfly Cloud environment. Documentation for specific resources and their usage can be found in the provider's official documentation.
Key resource types include:
- Dragonfly Datastore Configuration
- Network Configuration
- Connection Configuration
Example Usage
Here's a basic example of creating a Dragonfly instance:
resource "dfcloud_datastore" "cache" {
name = "frontend-cache"
location = {
region = "us-central1"
provider = "gcp"
}
tier = {
max_memory_bytes = 3000000000
performance_tier = "dev"
replicas = 1
}
dragonfly = {
cache_mode = true
}
}