Skip to main content

Beta access

The Runlayer Terraform provider is currently in beta. If you need help — private network access when your Runlayer API is not public, or the right base URL for your environment:

What you need

  • Terraform CLI 1.0 or later (OpenTofu works too)
  • Network access to your Runlayer API
  • A Runlayer user API key
The provider installs from Runlayer’s registry at downloads.runlayer.com with a plain terraform init — no credentials, no manual downloads.

Setup

1

Get private access first

If your Runlayer API is only reachable over VPN or another private network, make sure that is working before you start Terraform.
2

Declare the provider

3

Export your Runlayer credentials

Use a user API key here.Organization API keys are not sufficient for Terraform resource management endpoints such as policy creation.
RUNLAYER_BASE_URL should be the API base URL for your environment. If you are not sure which URL to use, ask us.
4

Optional: set the base URL in the provider block

If you prefer explicit provider configuration instead of environment variables, use the provider’s base_url and api_key arguments:
If you use this form, the variable name can be runlayer_base_url, but the provider argument itself is base_url.
5

Run Terraform

terraform init downloads the provider from the Runlayer registry and verifies its checksum and GPG signature.
6

Verify the setup

A good first check is:
  • terraform init installs the provider and writes it to .terraform.lock.hcl
  • once you add a real resource, terraform plan reaches the Runlayer API instead of failing on auth, host, or network setup

Using variables for users, groups, and roles

If you want stable references in Terraform, declare variables like this:
Then use them in resources:

How the CLI can help

The CLI includes uvx runlayer terraform export to generate a tfvars file with stable names for users, groups, and roles. Example:
Example output:
That file can be loaded by Terraform and referenced like:
This is useful when one person refreshes IDs occasionally and the rest of the Terraform code stays readable.

Resources

Provider 1.0 manages the full Runlayer surface: Data sources: runlayer_server, runlayer_policy, runlayer_server_security_setting, runlayer_deployment, runlayer_agent_account, runlayer_group, runlayer_role, runlayer_user.

Deployment example

The YAML has the same shape as runlayer.yaml. Build and push the image in CI, then stamp the digest into the YAML.

Agent account example

client_secret is returned once, on create, and can never be read again. It stays in Terraform state (treat state as a secret); an account imported after creation has no secret — rotate credentials in the app if you need one.

Upgrading from 0.10

Provider 1.0 is a breaking release:
  • Policy value fields must be valid JSON. Wrap plain strings with jsonencode: value = "delete" becomes value = jsonencode("delete"). Existing policy states need a re-import: terraform state rm the policy, update the config, then terraform import.
  • Minimum backend version: 2026-08-19. Ask us if you are unsure what your environment runs.
  • Registering a deployment’s connector on first apply requires a user API key (organization keys cannot register connectors yet).

Policy examples

These examples are based on the provider e2e coverage and show common policy shapes.

Allow one group full access to one server

Allow one group read-only access to a server

Deny one group access to one server

Deny tools by name prefix

Deny access outside a private IP range

Deny agent accounts without a production attribute

Deny everything except a small read-only tool set

Troubleshooting

  • terraform init cannot find the provider: check the source is exactly downloads.runlayer.com/runlayer/runlayer and that outbound HTTPS to downloads.runlayer.com is allowed
  • Terraform still uses an old manual install: remove any dev_overrides block for the provider from your Terraform CLI config (~/.terraformrc or TF_CLI_CONFIG_FILE), then re-run terraform init
  • terraform apply returns 403 Forbidden: make sure you are using a user API key, not an organization API key
  • API calls fail: verify RUNLAYER_API_KEY
  • API calls hit the wrong environment: verify RUNLAYER_BASE_URL
  • Requests time out or refuse to connect: confirm private network access first