mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Add ability to specify Terraform Cloud Project in cloud block (#33489)
* Add ability to specify Terraform Cloud Project in cloud block Adds project configuration to the workspaces section of the cloud block. Also configurable via the `TF_CLOUD_PROJECT` environment variable. When a project is configured, the following behaviors will occur: - `terraform init` with workspaces.name configured will create the workspace in the given project - `terraform workspace new <name>` with workspaces.tags configured will create workspaces in the given project - `terraform workspace list` will list workspaces only from the given project The following behaviors are NOT affected by project configuration - `terraform workspace delete <name>` does not validate the workspace's inclusion in the given project - When initializing a workspace that already exists in Terraform Cloud, the workspace's parent project is NOT validated against the given project Adds tests for cloud block configuration of project Update changelog * Update cloud block docs * Fix typos and changelog entry * Add speculative project lookup early in the cloud initialize process to capture inability to find a configured project * Add project config for alias test
This commit is contained in:
@@ -35,6 +35,7 @@ terraform {
|
||||
hostname = "app.terraform.io" # Optional; defaults to app.terraform.io
|
||||
|
||||
workspaces {
|
||||
project = "networking-development"
|
||||
tags = ["networking", "source:cli"]
|
||||
}
|
||||
}
|
||||
@@ -75,6 +76,10 @@ The `cloud` block supports the following configuration arguments:
|
||||
directory, and cannot manage workspaces from the CLI (e.g. `terraform workspace select` or
|
||||
`terraform workspace new`). This option conflicts with `tags`.
|
||||
|
||||
- `project` - (Optional) The name of a Terraform Cloud project. Workspaces that need created will
|
||||
will be created within this project. `terraform workspace list` will be filtered by workspaces
|
||||
in the supplied project.
|
||||
|
||||
- `hostname` - (Optional) The hostname of a Terraform Enterprise installation, if using Terraform
|
||||
Enterprise. Defaults to Terraform Cloud (app.terraform.io).
|
||||
|
||||
@@ -98,6 +103,8 @@ Use the following environment variables to configure the `cloud` block:
|
||||
|
||||
- `TF_CLOUD_HOSTNAME` - The hostname of a Terraform Enterprise installation. Terraform reads this when `hostname` is omitted from the `cloud` block. If both are specified, the configuration takes precedence.
|
||||
|
||||
- `TF_CLOUD_PROJECT` - The name of a Terraform Cloud project. Terraform reads this when `workspaces.project` is omitted from the `cloud` block. If both are specified, the cloud block configuration takes precedence.
|
||||
|
||||
- `TF_WORKSPACE` - The name of a single Terraform Cloud workspace. Terraform reads this when `workspaces` is omitted from the `cloud` block. Terraform Cloud will not create a new workspace from this variable; the workspace must exist in the specified organization. You can set `TF_WORKSPACE` if the `cloud` block uses tags. However, the value of `TF_WORKSPACE` must be included in the set of tags. This variable also selects the workspace in your local environment. Refer to [TF_WORKSPACE](/terraform/cli/config/environment-variables#tf_workspace) for details.
|
||||
|
||||
## Excluding Files from Upload with .terraformignore
|
||||
|
||||
Reference in New Issue
Block a user