Skip to main content

Terraform

TerraformExternal LinkThis link leads to an external website and will open in a new tab provides Infrastructure-as-Code (IaC) management for Files.com administrative resources. It enables versioned configuration, repeatable deployments, and safer automation across environments.

Terraform users define and configure data center infrastructure using a declarative configuration language known as Terraform Configuration LanguageExternal LinkThis link leads to an external website and will open in a new tab, or optionally JSONExternal LinkThis link leads to an external website and will open in a new tab.

The Files.com Provider for Terraform allows you to automate the management of your Files.com site, including resources representing users, groups, folders, share links, inboxes, automations, security, encryption, access protocols, permissions, remote servers, remote syncs, data governance, and moreExternal LinkThis link leads to an external website and will open in a new tab.

Terraform can be used both for new greenfield Files.com sites and for existing sites where configuration already exists. In greenfield scenarios, resources can be created directly through Terraform. In existing sites, resources must be imported before Terraform is applied.

Once a Files.com resource is managed by Terraform, Terraform becomes the authoritative source of configuration for that resource. Make changes through Terraform rather than through the Files.com UI or API to avoid configuration drift.

Refer to our Terraform Best Practices guide for more information about using Terraform with Files.com.

Getting Started with Terraform

  1. Install TerraformExternal LinkThis link leads to an external website and will open in a new tab
  2. Define or import a Terraform ConfigurationExternal LinkThis link leads to an external website and will open in a new tab for your Files.com resourcesExternal LinkThis link leads to an external website and will open in a new tab
  3. Run TerraformExternal LinkThis link leads to an external website and will open in a new tab

Terraform will provision and de-provision your Files.com resources based upon the configuration you defined.

Files.com Provider Configuration

The Files.com ProviderExternal LinkThis link leads to an external website and will open in a new tab needs to be configured with authentication credentials for your Files.com site. The Provider uses a Files.com API Key to authenticate.

The authorizations and permissions will match those of the associated with the API Key. For example, an API Key of a site administrator will be able to manage all resources while an API Key of a non-administrator can only manage that user's resources.

Connection Information

Ask your Files.com administrator to provide you with an API Key for the required user account or generate your own API Key within your Files.com user account. The Provider uses a single Files.com API Key.

Use the following Terraform configuration definitions to specify your connection and authentication to Files.com:

# Specify that we want to use the Files.com Provider

terraform {
  required_providers {
    files = {
      source = "Files-com/files"
    }
  }
}

# Configure the Files.com Provider with your API Key and site URL

provider "files" {
  api_key = "YOUR_API_KEY"
  endpoint_override = "https://MYSITE.files.com"
}

Managing Resources

Refer to the Terraform Provider online documentationExternal LinkThis link leads to an external website and will open in a new tab and the Files.com API documentation for Terraform for details about the resources that can be managed.

Importing Existing Resources

Terraform configurations sometimes begin by importing existing Files.com resources rather than creating new ones. Write the resource definitions to match the existing configuration as closely as possible, and perform imports incrementally.

After importing a resource, Terraform plans should be reviewed to confirm that no changes are proposed. Terraform should not be applied until imports are complete and validated.

Resource Examples

As an onboarding example, to create a partner account on your Files.com site, place them into a group, create a folder for them, and assign them permission to the folder, use the following sample configuration:

// Create Folder

resource "files_folder" "acme_partner_folder" {
  path = "partners/acme"
}

// Create Group

resource "files_group" "partners_group" {
  notes              = "This group is for all partners."
  ftp_permission     = true
  sftp_permission    = true
  dav_permission     = false
  restapi_permission = true
  name               = "Partners"
}

// Create Partner Account

resource "files_user" "acme_user" {
  email                 = "jane@acme.com"
  authentication_method = "password"
  name                  = "Jane Doe"
  company               = "ACME Corp"
  group_ids             = "${files_group.partners_group.id}"
  notes                 = "Internal notes about this partner."
  password              = "ARea11y5tr0ngP@ssw0rd"
  self_managed          = "true"
  time_zone             = "Pacific Time (US & Canada)"
  user_root             = "partners/acme"
  username              = "jane_acme"
}

// Set Folder Permission for Acme Partner

resource "files_permission" "acme_partner_permission" {
  path       = files_folder.acme_partner_folder.path
  username   = files_user.acme_user.username
  permission = "full"
}

Get The File Orchestration Platform Today

4,000+ organizations trust Files.com for mission-critical file operations. Start your free trial now and build your first flow in 60 seconds.

No credit card required • 7-day free trial • Setup in minutes