Directory Quotas Example¶
This example demonstrates how to manage directory quotas on an existing Qumulo cluster.
Features¶
- Basic quota on user home directories
- Large quota for shared data directories
- Department quotas using
for_eachwith TB-based configuration - Project quotas using
for_eachwith GB-based configuration - Capacity usage monitoring via computed attributes
Prerequisites¶
- An existing Qumulo cluster with REST API access
- Admin credentials for the cluster
- Network connectivity to the cluster endpoint
- Important: The directories must already exist on the cluster before setting quotas
Usage¶
-
Create the directories on your cluster (if they don't exist):
-
Initialize, plan, and apply with your cluster variables:
Or create a terraform.tfvars file with your values and run terraform apply without -var flags.
Configuration¶
Variables¶
| Name | Description | Type | Required |
|---|---|---|---|
cluster_endpoint |
Qumulo cluster REST API endpoint | string |
Yes |
cluster_username |
Cluster admin username | string |
No (default: admin) |
cluster_password |
Cluster admin password | string |
Yes |
department_quotas |
Map of department quota configs | map(object) |
No |
projects |
Map of project names to quota size in GB | map(number) |
No |
Outputs¶
| Name | Description |
|---|---|
user_homes_quota |
User homes quota details including usage |
shared_data_quota |
Shared data quota details including usage |
department_quotas |
Map of department names to quota details |
project_quotas |
Map of project names to quota IDs |
Directory Quota Resource¶
The qumulo_directory_quota resource creates a storage quota on a directory:
resource "qumulo_directory_quota" "example" {
connection_profile = "cluster1"
directory_path = "/data/user_home"
limit = "1099511627776" # 1TB in bytes
}
Arguments¶
| Name | Description | Required |
|---|---|---|
connection_profile |
Named provider connection profile to use | Yes |
directory_path |
Path to the directory (must exist) | Yes |
limit |
Quota limit in bytes (as string for precision) | Yes |
Attributes¶
| Name | Description |
|---|---|
id |
Unique ID of the directory |
directory_id |
Directory ID (same as id) |
capacity_usage |
Current storage usage in bytes |
Quota Size Reference¶
Common quota sizes in bytes:
| Size | Bytes |
|---|---|
| 100 GB | 107374182400 |
| 500 GB | 536870912000 |
| 1 TB | 1099511627776 |
| 5 TB | 5497558138880 |
| 10 TB | 10995116277760 |
| 50 TB | 54975581388800 |
| 100 TB | 109951162777600 |
Converting in Terraform¶
# GB to bytes
limit = tostring(var.quota_gb * 1073741824)
# TB to bytes
limit = tostring(var.quota_tb * 1099511627776)
Behavior Notes¶
Path Changes Require Replacement¶
Changing directory_path will destroy the quota and create a new one on the new directory. This is because quotas are tied to a specific directory ID.
# Changing this path destroys the old quota and creates a new one
directory_path = "/new/path" # Forces replacement
Directory Moves¶
If a directory is renamed or moved on the cluster (outside of Terraform), the quota follows it because quotas are tracked by directory ID. On the next terraform plan, the directory_path attribute will show the new path.
Quota Already Exists¶
If a quota already exists on a directory, the create operation will fail with a conflict error. Use terraform import to bring existing quotas under management:
Security Considerations¶
- Store
cluster_passwordin a secure location (environment variable, secrets manager) - Use appropriate quota limits to prevent storage exhaustion
- Monitor
capacity_usageto track storage consumption - Consider alerting when usage approaches the limit
Multi-Cluster Example¶
Manage quotas across multiple clusters using for_each:
variable "clusters" {
type = map(object({
endpoint = string
username = string
password = string
}))
}
provider "qumulo" {
connection_profiles = [
for name, config in var.clusters : {
name = name
endpoint = config.endpoint
username = config.username
password = config.password
}
]
}
resource "qumulo_directory_quota" "shared" {
for_each = var.clusters
connection_profile = each.key
directory_path = "/shared"
limit = "10995116277760" # 10TB
}
Full Configuration¶
# Example: Managing Directory Quotas on a Qumulo Cluster
#
# This example demonstrates how to create and manage directory quotas
# on an existing Qumulo cluster using the qumulo_directory_quota resource.
terraform {
required_providers {
qumulo = {
source = "qumulo-terraform-registry.s3.us-east-1.amazonaws.com/qumulo/qumulo"
version = "~> 1.0"
}
}
}
variable "cluster_endpoint" {
description = "Qumulo cluster REST API endpoint (e.g., https://cluster:8000)"
type = string
}
variable "cluster_username" {
description = "Qumulo cluster admin username"
type = string
default = "admin"
}
variable "cluster_password" {
description = "Qumulo cluster admin password"
type = string
sensitive = true
}
# Define connection profile for the cluster
provider "qumulo" {
connection_profiles = [
{
name = "cluster1"
endpoint = var.cluster_endpoint
username = var.cluster_username
password = var.cluster_password
insecure_skip_verify = true # Required for clusters with self-signed certificates
}
]
}
# Basic quota on a user home directory (1TB limit)
resource "qumulo_directory_quota" "user_homes" {
connection_profile = "cluster1"
directory_path = "/home"
limit = "1099511627776" # 1TB in bytes
}
# Large quota for shared data directory (10TB limit)
resource "qumulo_directory_quota" "shared_data" {
connection_profile = "cluster1"
directory_path = "/shared"
limit = "10995116277760" # 10TB in bytes
}
# Department quotas using for_each
variable "department_quotas" {
description = "Map of department names to their quota configuration"
type = map(object({
path = string
limit_tb = number
}))
default = {
engineering = {
path = "/departments/engineering"
limit_tb = 5
}
marketing = {
path = "/departments/marketing"
limit_tb = 2
}
research = {
path = "/departments/research"
limit_tb = 10
}
finance = {
path = "/departments/finance"
limit_tb = 1
}
}
}
resource "qumulo_directory_quota" "departments" {
for_each = var.department_quotas
connection_profile = "cluster1"
directory_path = each.value.path
# Convert TB to bytes: TB * 1024^4
limit = tostring(each.value.limit_tb * 1099511627776)
}
# Project quotas with different sizes
variable "projects" {
description = "Map of project names to their quota in GB"
type = map(number)
default = {
"project-alpha" = 500 # 500GB
"project-beta" = 1000 # 1TB
"project-gamma" = 2000 # 2TB
}
}
resource "qumulo_directory_quota" "projects" {
for_each = var.projects
connection_profile = "cluster1"
directory_path = "/projects/${each.key}"
# Convert GB to bytes: GB * 1024^3
limit = tostring(each.value * 1073741824)
}
# Outputs
output "user_homes_quota" {
description = "User homes quota details"
value = {
id = qumulo_directory_quota.user_homes.id
directory_id = qumulo_directory_quota.user_homes.directory_id
path = qumulo_directory_quota.user_homes.directory_path
limit = qumulo_directory_quota.user_homes.limit
capacity_usage = qumulo_directory_quota.user_homes.capacity_usage
}
}
output "shared_data_quota" {
description = "Shared data quota details"
value = {
id = qumulo_directory_quota.shared_data.id
path = qumulo_directory_quota.shared_data.directory_path
limit = qumulo_directory_quota.shared_data.limit
capacity_usage = qumulo_directory_quota.shared_data.capacity_usage
}
}
output "department_quotas" {
description = "Map of department names to their quota details"
value = {
for k, v in qumulo_directory_quota.departments : k => {
id = v.id
path = v.directory_path
limit = v.limit
capacity_usage = v.capacity_usage
}
}
}
output "project_quotas" {
description = "Map of project names to their quota IDs"
value = { for k, v in qumulo_directory_quota.projects : k => v.id }
}