Skip to main content

OpenTofu

OpenTofu, an open-source, community-driven fork of Terraform, lets you manage your Files.com resources using Infrastructure-as-Code (IaC) processes.

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

The Files.com Provider for OpenTofu allows you to automate the management of your Files.com site, including resources such as users, groups, folders, share links, inboxes, automations, security, encryption, access protocols, permissions, remote servers, remote syncs, data governance, and more.

Getting Started with OpenTofu

  1. Install OpenTofuExternal LinkThis link leads to an external website and will open in a new tab
  2. Define an OpenTofu 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 OpenTofuExternal LinkThis link leads to an external website and will open in a new tab

OpenTofu 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 OpenTofu 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 OpenTofu Provider online documentationExternal LinkThis link leads to an external website and will open in a new tab and the Files.com API documentation for TerraformExternal LinkThis link leads to an external website and will open in a new tab for details about the resources that can be managed.

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 Instant Access to Files.com

The button below will take you to our Free Trial signup page. Click on the white "Start My Free Trial" button, then fill out the short form on the next page. Your account will be activated instantly. You can dive in and start yourself or let us help. The choice is yours.