Skip to main content
The Archil Terraform provider enables you to manage Archil resources using Infrastructure as Code. It supports creating and managing disks, API tokens, and disk user authorizations.

Installation

Add the provider to your required_providers block:
terraform {
  required_providers {
    archil = {
      source = "archil-data/archil"
    }
  }
}
Then run terraform init to install the provider.

Provider Configuration

provider "archil" {
  api_key = var.archil_api_key
  region  = "aws-us-east-1"
}

Arguments

ArgumentDescriptionRequired
api_keyAPI key for authentication. Can also be set via ARCHIL_API_KEY environment variable. Accepts the key with or without the key- prefix.Yes
regionArchil region (e.g., aws-us-east-1). Can also be set via ARCHIL_REGION. Default: aws-us-east-1. See Region Availability for all regions.No
endpointOverride the API endpoint URL. Can also be set via ARCHIL_ENDPOINT.No
Store your API key securely. Use a terraform.tfvars file (and add it to .gitignore) or an environment variable rather than hardcoding the key in your configuration.

Resources

archil_disk

Creates and manages an Archil disk with a storage mount.
resource "archil_disk" "example" {
  name = "my-disk"

  mount {
    type        = "s3"
    bucket_name = "my-s3-bucket"
  }
}

Arguments

ArgumentDescriptionRequired
nameDisk name (1-100 chars, alphanumeric, dashes, underscores).Yes
mountStorage mount configuration block (exactly one required).Yes

Mount Block Arguments

ArgumentDescriptionRequired
typeMount type: s3, gcs, r2, s3-compatible, or azure-blob.Yes
bucket_nameBucket or container name.No
bucket_endpointStorage endpoint URL (auto-populated for S3).No
bucket_prefixPrefix within the bucket.No
access_key_idAccess key ID (sensitive).No
secret_access_keySecret access key (sensitive).No
session_tokenSession token for temporary credentials (sensitive).No
session_idSession identifier for IAM role-based auth. Auto-generated when no access keys are provided.No
container_nameAzure blob container name.No
endpointAzure blob endpoint URL.No
storage_account_nameAzure storage account name.No
tenant_idAzure AD tenant ID.No
client_idAzure AD client ID.No
client_secretAzure AD client secret (sensitive).No
All disk attributes require replacement — changing any attribute will destroy and recreate the disk.

Attributes

AttributeDescription
idDisk ID (e.g., dsk-0123456789abcdef).
statusDisk status (e.g., available).
organizationOwning organization.
provider_nameCloud provider (e.g., aws).
regionDisk region (e.g., aws-us-east-1).
created_atCreation timestamp.
data_sizeTotal data size in bytes.

archil_api_token

Creates and manages an Archil API token for programmatic access.
resource "archil_api_token" "example" {
  name        = "ci-token"
  description = "Token for CI/CD pipelines"
}

Arguments

ArgumentDescriptionRequired
nameToken name (1-100 chars).Yes
descriptionToken description (max 500 chars).No

Attributes

AttributeDescription
idToken ID (hash).
tokenFull token value (sensitive, only available at creation).
token_suffixLast 4 characters of the token.
created_atCreation timestamp.

archil_disk_user

Adds an authorized user to an Archil disk. Supports token-based and AWS STS authentication.
resource "archil_disk_user" "example" {
  disk_id   = archil_disk.example.id
  type      = "token"
  principal = archil_api_token.example.token
  nickname  = "ci-pipeline"
}

Arguments

ArgumentDescriptionRequired
disk_idID of the disk to add the user to.Yes
typeUser type: token or awssts.Yes
principalToken value or IAM ARN (sensitive).Yes
nicknameNickname for the user (required when type = "token").No

Attributes

AttributeDescription
token_suffixLast 4 characters of the token.
created_atCreation timestamp.

Data Sources

archil_disk

Look up an existing Archil disk by ID or name.
data "archil_disk" "production" {
  name = "production-disk"
}

Arguments

Exactly one of id or name must be set.
ArgumentDescription
idDisk ID to look up.
nameDisk name to look up.

Attributes

AttributeDescription
idDisk ID.
nameDisk name.
statusDisk status.
organizationOwning organization.
provider_nameCloud provider.
regionDisk region.
created_atCreation timestamp.
data_sizeTotal data size in bytes.

Full Example

This example creates a disk with an S3 mount, an API token, and authorizes the token to access the disk:
terraform {
  required_providers {
    archil = {
      source = "archil-data/archil"
    }
  }
}

provider "archil" {
  api_key = var.archil_api_key
  region  = "aws-us-east-1"
}

variable "archil_api_key" {
  type      = string
  sensitive = true
}

resource "archil_disk" "app" {
  name = "my-app-disk"

  mount {
    type        = "s3"
    bucket_name = "my-app-bucket"
  }
}

resource "archil_api_token" "app" {
  name        = "app-token"
  description = "Token for application servers"
}

resource "archil_disk_user" "app" {
  disk_id   = archil_disk.app.id
  type      = "token"
  principal = archil_api_token.app.token
  nickname  = "app-servers"
}

data "archil_disk" "app" {
  name       = archil_disk.app.name
  depends_on = [archil_disk.app]
}

output "disk_id" {
  value = archil_disk.app.id
}

output "disk_status" {
  value = archil_disk.app.status
}

Import

Disks can be imported using their ID:
terraform import archil_disk.example dsk-0123456789abcdef