run opentofu-plan apply
  • 13 Nov 2024
  • Dark
    Light
  • PDF

run opentofu-plan apply

  • Dark
    Light
  • PDF

Article summary

iagctl run opentofu-plan apply

Execute init and apply against an OpenTofu plan service

Synopsis

This command will execute tofu init and tofu apply against an OpenTofu plan service and display the resulting state file, stdout, stderr, and return code returned from OpenTofu as well as some additional execution time information.

Runtime variables called vars by OpenTofu can be specified using the --set flag. The --set flag takes in a key=value syntax. Any variables passed in using --set will be validated against the decorator if one was defined during service creation.

To view helpful information about what inputs are accepted by a particular service, run this command with the service name and the --use flag.

iagctl run opentofu-plan apply <service-name> [flags]

When running an OpenTofu service, one can specify a state file that will be referenced while executing the plan using the --state flag.

  • The --state flag accepts JSON written directly to the CLI as well as the path to an existing state-file using the @ symbol.
  • If a path is specified, the resulting state file will be written to that path unless --state-out is used.
  • If you would like to specify a separate path for the resulting state file to be written to, you can use the --state-out flag.

Examples

OpenTofu Service

Run apply against an OpenTofu service.

iagctl run opentofu-plan apply my-opentofu-service

Setting Arguments

Run an OpenTofu plan service called my-opentofu-service that takes in an argument of interface.

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

Specify a State File Directly in CLI

Run apply against an OpenTofu service and provide the state file JSON directly within the CLI. OpenTofu will reference the provided state file during execution.

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

Specify a State File Using Its Path

Run apply against an OpenTofu service and provide a state file via path to the file. OpenTofu will reference the provided state file during execution.

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

Specify a State File Using Its Path and Location

Run apply against an OpenTofu service and provide a state file via path to the file as well as a location to write the resulting state file.

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

Options

-h, --help                 Help for apply
--set stringArray          Sets an input argument to be passed into the script via CLI when executed. Arguments are sent in the order in which they are defined and are appended to the arguments already defined on the opentofu service. They must follow the key=value syntax and the service must support the inputs.
--state string             The state file to utilize while running the plan. If a file path is specified with '@' the resulting state file will be saved there as well (unless state-out is specified).
--state-out string         Path to write the resulting state file that is different than --state. This can be used to preserve the old state file.
--use                      Display usage of the plan.

Options Inherited from Parent Commands

--config string   Path to the configuration file
--raw             Displays the result of the command in its raw format
--verbose         Enable verbose output

CLI References

See related run commands:

For all CLI commands see → Command References Index


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.