--- page_title: "ona_automation Resource - ona" subcategory: "Integrations and Automation" description: |- Persistent Ona automation. New automations use the Codex agent. Existing Ona-agent automations can be imported, read, and deleted; change agent to codex to migrate one in place. Creating automations requires a permitted user credential; the Ona API rejects automation creation by service accounts. A caller changing automation triggers or actions must own the current user executor or set the executor to themselves or a service account. Removing this resource uses graceful deletion: Ona immediately deletes idle automations, but cancels active executions and finishes their cleanup asynchronously. --- # ona_automation (Resource) Persistent Ona automation. New automations use the Codex agent. Existing Ona-agent automations can be imported, read, and deleted; change `agent` to `codex` to migrate one in place. Creating automations requires a permitted user credential; the Ona API rejects automation creation by service accounts. A caller changing automation triggers or actions must own the current user executor or set the executor to themselves or a service account. Removing this resource uses graceful deletion: Ona immediately deletes idle automations, but cancels active executions and finishes their cleanup asynchronously. For product context, see [Background automations](https://ona.com/docs/ona/automations/overview), [Configure Automations](https://ona.com/docs/ona/automations/configure-automations), and [Webhooks](https://ona.com/docs/ona/automations/webhooks). ## Automation support and limitations The provider supports: - Manual, scheduled, and pull-request triggers - Project, repository, agent-prompt, and inherited trigger contexts - Shell-task, agent-prompt, and pull-request action steps - Executors, execution limits, and disabling automations - Codex agent selection and in-place migration from the Ona agent - Codex model, reasoning-effort, and service-tier settings It does not model: - Top-level report actions - Report steps The `agent` attribute defaults to `codex`. Imported automations that use the Ona agent report `ona`; change `agent` to `codex`, or omit it so the default applies, to migrate the existing automation in place. The automation ID and webhook URL remain unchanged. New automations and updates cannot use `agent = "ona"`. Legacy pull-request triggers without a webhook or integration cannot be imported or managed. ## Example Usage ```terraform resource "ona_automation" "nightly_checks" { name = "Nightly checks" description = "Runs repository checks every weekday." agent = "codex" disabled = false executor = { id = "" principal = "service_account" } codex_settings = { model = "gpt-5.6-sol" reasoning_effort = "high" service_tier = "fast" } triggers = [ { manual = {} context = { projects = { project_ids = [""] } } }, { time = { cron_expression = "0 9 * * 1-5" } context = { repositories = { repository_urls = ["https://github.com/example-organization/example-repository"] environment_class_id = "" } } } ] action = { limits = { max_parallel = 2 max_total = 10 max_time = "30m" } steps = [ { agent = { prompt = "Review the repository and identify failing checks." } }, { task = { command = "make test" } } ] } } ``` ## Schema ### Required - `action` (Attributes) Automation action and its ordered execution steps. (see [below for nested schema](#nestedatt--action)) - `name` (String) Automation display name. Must be between 1 and 80 characters. - `triggers` (Attributes List) Ordered automation triggers. Configure between 1 and 10 entries. (see [below for nested schema](#nestedatt--triggers)) ### Optional - `agent` (String) Automation agent. Supported values are `codex` and `ona`; the default is `codex`. New automations must use `codex`. Imported Ona-agent automations report `ona`; change this value to `codex` to migrate the existing automation in place. An omitted agent on an imported Ona-agent automation also plans that migration because the default is `codex`. - `codex_settings` (Attributes) Codex model, reasoning, and service settings. Omit this object or use an empty object to select runtime defaults. Ona applies these settings only to Codex automations. (see [below for nested schema](#nestedatt--codex_settings)) - `description` (String) Optional automation description. Must not exceed 500 characters. Set an empty string to clear it. - `disabled` (Boolean) Whether automatic and manual automation starts are disabled. Defaults to `false`. - `executor` (Attributes) Identity that executes the automation. Omit to use the creating user. A user executor must be the API caller; a service-account executor may be selected by ID. Removing this block retains the resolved remote executor because the API has no clear operation. (see [below for nested schema](#nestedatt--executor)) ### Read-Only - `created_at` (String) Time when the automation was created, in RFC 3339 format. - `creator` (Attributes) Identity that created the automation. (see [below for nested schema](#nestedatt--creator)) - `id` (String) Automation ID. Use this value as the Terraform import ID. - `updated_at` (String) Time when the automation was last updated, in RFC 3339 format. - `webhook_url` (String) Generated automation webhook URL. The signing secret is not read or stored. ### Nested Schema for `action` Required: - `limits` (Attributes) Action execution limits. Organization tiering may impose lower server-side caps. (see [below for nested schema](#nestedatt--action--limits)) - `steps` (Attributes List) Ordered action steps. Configure between 1 and 50 entries. (see [below for nested schema](#nestedatt--action--steps)) ### Nested Schema for `action.limits` Required: - `max_parallel` (Number) Maximum concurrent actions, from 1 through 25. Must not exceed max_total. - `max_total` (Number) Maximum total actions, from 1 through 1000. Optional: - `max_time` (String) Optional maximum time per execution action, as a Go duration string such as `30m` or `2h`. ### Nested Schema for `action.steps` Optional: - `agent` (Attributes) Agent prompt step. (see [below for nested schema](#nestedatt--action--steps--agent)) - `pull_request` (Attributes) Pull-request creation step. (see [below for nested schema](#nestedatt--action--steps--pull_request)) - `task` (Attributes) Shell task step. (see [below for nested schema](#nestedatt--action--steps--task)) ### Nested Schema for `action.steps.agent` Required: - `prompt` (String) Prompt for the agent. Must be between 1 and 20,000 characters. ### Nested Schema for `action.steps.pull_request` Required: - `branch` (String) Pull-request branch. Must be between 1 and 255 characters. - `title` (String) Pull-request title. Must be between 1 and 500 characters. Optional: - `description` (String) Pull-request description. Must not exceed 20,000 characters. - `draft` (Boolean) Whether to create the pull request as a draft. Defaults to `false`. ### Nested Schema for `action.steps.task` Required: - `command` (String) Command to run. Must be between 1 and 20,000 characters. ### Nested Schema for `triggers` Required: - `context` (Attributes) Execution context. Configure exactly one context variant. (see [below for nested schema](#nestedatt--triggers--context)) Optional: - `manual` (Attributes) Manual trigger. (see [below for nested schema](#nestedatt--triggers--manual)) - `pull_request` (Attributes) Pull-request trigger. Configure at least one event and at least one webhook or integration ID. (see [below for nested schema](#nestedatt--triggers--pull_request)) - `time` (Attributes) Time-based trigger. (see [below for nested schema](#nestedatt--triggers--time)) ### Nested Schema for `triggers.context` Optional: - `agent` (Attributes) Agent-managed execution context. (see [below for nested schema](#nestedatt--triggers--context--agent)) - `from_trigger` (Attributes) Use context from the pull-request event. Valid only for pull_request triggers. (see [below for nested schema](#nestedatt--triggers--context--from_trigger)) - `projects` (Attributes) Project environments in which the automation runs. (see [below for nested schema](#nestedatt--triggers--context--projects)) - `repositories` (Attributes) Repository environments in which the automation runs. (see [below for nested schema](#nestedatt--triggers--context--repositories)) ### Nested Schema for `triggers.context.agent` Required: - `prompt` (String) Agent context prompt. Must be between 1 and 20,000 characters. ### Nested Schema for `triggers.context.from_trigger` ### Nested Schema for `triggers.context.projects` Required: - `project_ids` (Set of String) Project UUIDs. The API accepts up to 1000 entries. ### Nested Schema for `triggers.context.repositories` Required: - `environment_class_id` (String) Environment class UUID used for repository environments. Optional: - `repository_selector` (Attributes) SCM repository search selector. Do not combine with repository_urls. (see [below for nested schema](#nestedatt--triggers--context--repositories--repository_selector)) - `repository_urls` (Set of String) Explicit repository URLs. Configure 1 to 500 values, or use repository_selector. ### Nested Schema for `triggers.context.repositories.repository_selector` Required: - `repo_search_string` (String) SCM-specific repository search string. - `scm_host` (String) SCM host, such as `github.com` or `gitlab.com`. ### Nested Schema for `triggers.manual` ### Nested Schema for `triggers.pull_request` Required: - `events` (Set of String) Pull-request events: `opened`, `updated`, `approved`, `merged`, `closed`, `ready_for_review`, or `review_requested`. Optional: - `integration_id` (String) UUID of an integration that supplies events to this trigger. - `webhook_id` (String) UUID of a reusable webhook that activates this trigger. ### Nested Schema for `triggers.time` Required: - `cron_expression` (String) Five-field cron expression or supported cron descriptor. Must be between 1 and 100 characters. ### Nested Schema for `codex_settings` Optional: - `model` (String) Codex model. Supported values are `gpt-5.5`, `gpt-5.4`, `gpt-5.6-sol`, `gpt-5.6-terra`, and `gpt-5.6-luna`. Deprecated model values remain readable for existing automations but cannot be configured. - `reasoning_effort` (String) Codex reasoning effort. Supported values are `low`, `medium`, `high`, and `xhigh`. Feature-flagged `max` and `ultra` values remain readable for existing automations but cannot be configured. - `service_tier` (String) Codex service tier. The supported value is `fast`. ### Nested Schema for `executor` Optional: - `id` (String) Executor UUID. - `principal` (String) Executor principal type. Supported values are `user` and `service_account`. ### Nested Schema for `creator` Read-Only: - `id` (String) Subject UUID. - `principal` (String) Subject principal type. ## Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell #!/usr/bin/env sh terraform import ona_automation.nightly_checks 00000000-0000-0000-0000-000000000000 ```