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

run opentofu-plan destroy

  • Dark
    Light
  • PDF

Article summary

iagctl run opentofu-plan destroy

Execute init and destroy against an OpenTofu plan service

Synopsis

This command will execute a tofu init and a tofu destroy 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 destroy <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 destroy against an OpenTofu service.

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

Specify Runtime Var

Run destroy against an OpenTofu service and specify a var with a key of server_name and a value of somehostname.

iagctl run opentofu-plan destroy deployment-service \
--var server_name=somehostname

Specify State File Directly in CLI

Run destroy 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 destroy deployment-service \
--state '{"check_results":null,"outputs":{},"resources":[]}'

Specify State File Using Its Path

Run destroy 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 destroy deployment-service \
--state @opentofu.tfstate

Specify State File Using Its Path and Location

Run destroy 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 destroy deployment-service \
--state @opentofu.tfstate \
--state-out @resultingstate.tfstate

Options

-h, --help                 Help for destroy
--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.