Terraform provider
← Docs · Reference

Terraform provider

Manage apps, environment variables and custom domains from Terraform with a read-write API token.

The provider lives in the terraform-provider-railyard folder of the repository and reads RAILYARD_TOKEN (a read-write API token from Settings → Team → API tokens) and RAILYARD_API (default https://app.railyard.run).

terraform {
  required_providers { railyard = { source = "almokhtarbr/railyard" } }
}

provider "railyard" {}

resource "railyard_app" "web" {
  name    = "shop"
  git_url = "https://github.com/acme/shop"
  git_ref = "main"
  server  = "my-server-hostname" # optional; the team's first server otherwise
}

resource "railyard_env_var" "rails_env" {
  app_id = railyard_app.web.id
  key    = "RAILS_ENV"
  value  = "production"
}

resource "railyard_domain" "www" {
  app_id   = railyard_app.web.id
  hostname = "www.example.com"
}

Creating an app does not deploy it: push to the repository with auto-deploy on, or run railyard deploy. An app created this way still reads its repository (start command, port, Dockerfile, datastores); settings you pass explicitly win. Sealed variables keep their values.

Imports: terraform import railyard_app.web <app id> and terraform import railyard_env_var.x <app id>/<KEY>.

The provider is not yet on the Terraform Registry; build it from the folder and point dev_overrides at the binary, as its README shows.