iagctl create service opentofu-plan

Create a new OpenTofu plan service.

The iagctl create service opentofu-plan command creates an OpenTofu plan service in the gateway data store. You can then run the service with the iagctl run command. For more information, see Create gateway services.

Consider an OpenTofu plan in a repository called example-repo with the following directory layout:

$├── README.md
$├── deployment-plans
$│ ├── main.tf
$│ └── prod.tfvars

To create a service from the plan files in the deployment-plans directory, specify the repository with --repository and the subdirectory with --working-dir.

Prerequisites

Before you create an OpenTofu plan service, you need a repository that contains your plan files.

Syntax

$iagctl create service opentofu-plan <service-name> --repository <name> [flags]

Usage notes

Variables

Pass variables to the plan with the --var flag using key=value syntax. To reference a variables file in the repository, use --var-file. The file path must be relative to your --working-dir.

Decorators

You can attach a decorator to the service for input validation at runtime with the --decorator flag. For more information, see iagctl create decorator.

Examples

Create a basic OpenTofu plan service

The following example creates a service called my-opentofu-service where the plan files are at the root of the my-repo repository:

$iagctl create service opentofu-plan my-opentofu-service \
>--repository my-repo

Create an OpenTofu plan service with all options

The following example creates a service that specifies a working directory, variables, a variable file, a decorator, and metadata:

$iagctl create service opentofu-plan deployment-service \
>--repository example-repo \
>--working-dir deployment-plans \
>--var server_name=examplehostname \
>--var-file prod.tfvars \
>--decorator my-decorator \
>--description "An OpenTofu plan to deploy servers" \
>--tag servers

Options

$ --decorator string The decorator to associate with the service.
$ --description string A brief description of the service.
$ -h, --help Help for opentofu-plan.
$ --repository string The gateway repository that contains the OpenTofu plan.
$ --tag stringArray Metadata tags to associate with the service.
$ --var stringArray A variable as a key=value pair for OpenTofu to use during plan execution.
$ --var-file stringArray Path to a variable file for OpenTofu to use during plan execution. Relative to the working directory.
$ --working-dir string Path to the directory where the plan exists, relative to the repository root.

Options inherited from parent commands

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