> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/itential-gateway/5/iagctl/run-service-opentofu-plan/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # iagctl run service opentofu-plan Run an OpenTofu plan service. The `iagctl run service opentofu-plan` command executes an OpenTofu plan service and displays the resulting state file, `stdout`, `stderr`, return code, and execution time information. This command supports two subcommands: * `apply` — Runs `tofu init` and `tofu apply`. * `destroy` — Runs `tofu init` and `tofu destroy`. ## Syntax ```bash iagctl run service opentofu-plan apply [flags] ``` ```bash iagctl run service opentofu-plan destroy [flags] ``` ## Usage notes ### Runtime variables Use the `--set` flag to pass OpenTofu variables at runtime using `key=value` syntax. If you defined a decorator during service creation, Gateway validates all `--set` values against it. ### View accepted inputs Use the `--use` flag with the service name to display information about the inputs a service accepts: ```bash iagctl run service opentofu-plan apply --use ``` ### State files Use the `--state` flag to specify a state file for OpenTofu to reference during execution. The `--state` flag accepts inline JSON or a path to an existing state file using the `@` prefix. When you specify a file path with `@`, Gateway writes the resulting state file to that same path unless you use the `--state-out` flag to specify a different output path. When using a remote backend, state is managed by the backend and the `--state` and `--state-out` execution flags are typically not needed. ## Examples ### Apply an OpenTofu plan ```bash iagctl run service opentofu-plan apply my-opentofu-service ``` ### Destroy an OpenTofu plan ```bash iagctl run service opentofu-plan destroy my-opentofu-service ``` ### Pass runtime variables ```bash iagctl run service opentofu-plan apply my-opentofu-service \ --set interface=0/0/0 ``` ### Specify a state file as inline JSON ```bash iagctl run service opentofu-plan apply my-opentofu-service \ --state '{"check_results":null,"outputs":{},"resources":[]}' ``` ### Specify a state file by path ```bash iagctl run service opentofu-plan apply my-opentofu-service \ --state @opentofu.tfstate ``` ### Specify separate input and output state files ```bash iagctl run service opentofu-plan apply my-opentofu-service \ --state @opentofu.tfstate \ --state-out @resultingstate.tfstate ``` ## Options ```bash --profile string Specify the client profile to use (case-insensitive, defaults to [client] section) -h, --help Help for opentofu-plan --set stringArray Runtime input arguments as key=value pairs. Values are validated against the decorator, if one is defined. --state string State file for OpenTofu to reference during execution. Accepts inline JSON or a file path prefixed with '@'. When a file path is specified, the resulting state is written to the same path unless --state-out is set. --state-out string Path to write the resulting state file, separate from --state. Use this to preserve the original state file. --use Display usage of the service. ``` ## Options inherited from parent commands ```bash --profile string Specify the client profile to use (case-insensitive, defaults to [client] section) --config string Path to the configuration file --raw Display the result of the command in raw format --verbose Enable verbose output ```