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
Full schema reference
In your Runlayer app, open Help, then select Terraform Reference. The reference includes provider configuration, resource and data-source schemas, nested fields, examples, and resource import instructions. Each page shows the provider version it documents. Select the version to open its entry in the reference’s Changelog page, which lists notable resource and data-source changes by provider release.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
Pin 1.8.1 or later to use the resources added in 1.8: the detection, smart rule, team member and team group binding resources, and the new
runlayer_agent attributes. 1.8.0 was never published to the registry. If your backend runs 1.28.1227 through 1.28.1287 and uses the detection resources, pin 1.8.2 or later: 1.8.0 and 1.8.1 wrongly report the detections feature as off on those backends.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
The provider manages the resources below. Anything not listed here is still managed in the app or the API.The detection and smart rule resources need the
detections or smart-rules feature on your organization; contact Runlayer to enable it. While the feature is off, plan and apply fail with an error naming it, and Terraform keeps these resources in state, so turning the feature back on loses nothing.In
runlayer_detection_rule_setting, setting scope needs backend 1.28.1537 or later, and setting include_local_tools needs 1.28.1581 or later. On older backends, a plan that sets either fails with an error naming the version; leave them unset there. On backends 1.28.1438 to 1.28.1536, an apply that changes the rule also resets its scope to all.Two
runlayer_detection_outbound_entry resources for the same server and tool share one entry: the second adopts the first one’s entry, and destroying either deletes it. Manage each entry with one resource.runlayer_auto_sync_item imports by <entity_type>/<entity_id>, and an apply without import also adopts the existing item. sync_enabled = false is accepted only for skills, where it turns sync off org-wide; stop a server or plugin syncing by destroying its resource. team_ids applies to servers only, and an unset team_ids keeps the stored scope.runlayer_team_member and runlayer_team_group_binding have no import: declare the resource and apply, and it adopts the existing membership or binding. Removing a member fails while a group bound to the team still grants them membership; unbind the group first. A team keeps at least one owner, and its creator stays an owner.Moving an identity to the other list (in the app or the API) keeps its entry ID. Before the provider reads or deletes an entry, it checks which list the entry is in. If the entry has moved, the provider treats it as gone: it leaves the moved entry alone and plans to create the resource again in its own list.
runlayer_ai_watch_enforce_entry needs Runlayer 1.28.1171 or later. Runlayer releases that include the list check on entry reads and deletes do both in a single step. On earlier releases these are two requests, so a move that lands between them can still delete the moved entry.Importing existing resources
Most resources can be imported withterraform import. The ID to pass depends on the resource:
runlayer_team_member and runlayer_team_group_binding adopt an existing membership or binding on apply. The singletons (runlayer_organization, runlayer_security_scanner_settings, runlayer_ai_watch_enforce_settings, runlayer_ai_provider_recommended_model) and runlayer_server_tool_security_setting write their settings on apply, so declare them with the values you want.
To adopt many objects at once and let Terraform write their configuration, see Adopt Existing Resources.
Data sources
Every data source reads one existing object:- Servers and policies:
runlayer_server,runlayer_server_security_setting,runlayer_server_tool_security_setting,runlayer_policy,runlayer_policy_attribute_setting,runlayer_deployment - Security:
runlayer_security_scanner_settings,runlayer_ai_watch_enforce_settings,runlayer_ai_watch_enforce_entry,runlayer_ai_watch_user_scoped_policy,runlayer_detection_rule_setting,runlayer_detection_outbound_entry,runlayer_smart_rule,runlayer_smart_rule_test_case - Agents, plugins and skills:
runlayer_agent,runlayer_agent_account,runlayer_agent_schedule,runlayer_plugin,runlayer_skill,runlayer_auto_sync_item - People and organization:
runlayer_user,runlayer_group,runlayer_role,runlayer_team,runlayer_team_member,runlayer_team_group_binding,runlayer_organization - AI providers and the LLM gateway:
runlayer_ai_provider,runlayer_ai_provider_recommended_model,runlayer_llm_gateway_usage_rule,runlayer_llm_gateway_routing_rule,runlayer_llm_gateway_virtual_key
Deployment example
runlayer.yaml. Build and push the image in CI, then stamp the digest into the YAML.
Agent account example
Agent example
Some attributes are request-only: Terraform sends
servers, skill_ids, and env on create and update but does not refresh them from the API, because the API returns connectors in a different shape and masks env values. Changes made in the app to those three are not detected as drift. Use the computed server_count, tool_count, skill_count, and env_keys for read-side checks.description is generated by Runlayer from the prompt and is read-only in Terraform, as are harness and the usage limits (run_limits_by_model, daily_cost_limit_usd, weekly_cost_limit_usd). tags are returned sorted, so list them sorted to avoid a permanent diff.open_to_collaboration lets the agent work with agents that act for other people in your workspace. It needs backend 1.28.1590 or later. If you leave it out of config, Terraform keeps the value set in the app. The read-only my_last_used_at and my_run_count show your own last run and your run count over the last 30 days, for the user whose API key Terraform uses. They need backend 1.28.1543 or later.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