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

iagctl run service opentofu-plan apply <service-name> [flags]
iagctl run service opentofu-plan destroy <service-name> [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:

iagctl run service opentofu-plan apply <service-name> --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

iagctl run service opentofu-plan apply my-opentofu-service

Destroy an OpenTofu plan

iagctl run service opentofu-plan destroy my-opentofu-service

Pass runtime variables

iagctl run service opentofu-plan apply my-opentofu-service \
--set interface=0/0/0

Specify a state file as inline JSON

iagctl run service opentofu-plan apply my-opentofu-service \
--state '{"check_results":null,"outputs":{},"resources":[]}'

Specify a state file by path

iagctl run service opentofu-plan apply my-opentofu-service \
--state @opentofu.tfstate

Specify separate input and output state files

iagctl run service opentofu-plan apply my-opentofu-service \
--state @opentofu.tfstate \
--state-out @resultingstate.tfstate

Options

--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

--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