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:- Reach out to us in Slack
- Or email support@runlayer.com
What you need
- Terraform CLI 1.0 or later (OpenTofu works too)
- Network access to your Runlayer API
- A Runlayer user API key
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 If you use this form, the variable name can be
base_url and api_key arguments: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 initinstalls the provider and writes it to.terraform.lock.hcl- once you add a real resource,
terraform planreaches 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:How the CLI can help
The CLI includesuvx runlayer terraform export to generate a tfvars file with stable names for users, groups, and roles.
Example:
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
runlayer.yaml. Build and push the image in CI, then stamp the digest into the YAML.
Agent account example
Upgrading from 0.10
Provider 1.0 is a breaking release:- Policy
valuefields must be valid JSON. Wrap plain strings withjsonencode:value = "delete"becomesvalue = jsonencode("delete"). Existing policy states need a re-import:terraform state rmthe policy, update the config, thenterraform 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 initcannot find the provider: check thesourceis exactlydownloads.runlayer.com/runlayer/runlayerand that outbound HTTPS todownloads.runlayer.comis allowed- Terraform still uses an old manual install: remove any
dev_overridesblock for the provider from your Terraform CLI config (~/.terraformrcorTF_CLI_CONFIG_FILE), then re-runterraform init terraform applyreturns403 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