Terraform
This topic describes the parameters for configuring the tf-migrate CLI.
Configuration model
A tf-migrate configuration file supports the following parameters.
skip-dir: list of stringsprojects: list of objectsdir: stringworkspaces: list of objectsname: stringenv-vars:terraform-vars: list of strings
Specification
This section provides details about the fields you can configure in a tf-migrate configuration file.
skip-dir
Specifies a list of paths to directories you want tf-migrate to skip. This parameter is identical to using the -skip-dir command-line flag. By default, tf-migrate processes all child directories containing Terraform configuration files.
- Data type: List of strings
- Default: None
projects
Specifies a list of project configurations that align with local directories. The tf-migrate tool creates one project in HCP Terraform or Terraform Enterprise per configuration. In each project, tf-migrate creates one workspace per local workspace.
- Data type: List of objects
- Default: None
projects.dir
Specifies the relative or absolute path to the Terraform configuration to migrate.
- Data type: String
- Default: None
projects.workspaces
Specifies workspace configurations in the project. Terraform creates a workspace in HCP Terraform or Terraform Enterprise for each workspace configuration. The following table describes the attributes you can configure in each item in the list of workspaces:
| Attribute | Description | Data type | Default |
|---|---|---|---|
name | Specifies the name of the local workspace. | String | None |
env-vars | Specifies a map of environment variables to set during the migration. Each key must start with TF_VAR. You must specify env-vars, terraform-vars, or both. | Object | None |
terraform-vars | Specifies a list of Terraform variables files to use for configuring the workspace. Each file must end with either .tfvars or tfvars.json. You must specify terraform-vars, env-vars, or both. The path can be a relative or absolute path. | List of strings | None |
- Data type: List of objects
- Default: None
Example configuration file
In the following example, Terraform creates one project using data from the example/project1 directory. The project has a workspace named staging and a workspace named dev:
skip-dir = ["example/skip/dir1", "example/skip/dir2"]
projects = [
{
dir = "example/project1"
workspaces = [
{
name = "staging"
env-vars = {
"TF_VAR_region": "us-east-2"
}
terraform-vars = ["staging.tfvars"]
},
{
name = "dev"
terraform-vars = ["dev.tfvars"]
}
]
}
]