You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/terraform_workspace_remote.md
+14-9Lines changed: 14 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# terraform_workspace_remote
2
2
3
-
`terraform.workspace` should not be used with a "remote" backend with remote execution.
3
+
`terraform.workspace` should not be used with a "remote" backend with remote execution in Terraform v1.0.x.
4
4
5
5
If remote operations are [disabled](https://www.terraform.io/docs/cloud/run/index.html#disabling-remote-operations) for your workspace, you can safely disable this rule:
This rule looks at `required_version` for Terraform version estimation. If the `required_version` is not declared, it is assumed that you are using a more recent version.
14
+
13
15
> This rule is enabled by "recommended" preset.
14
16
15
17
## Example
16
18
17
19
```hcl
18
20
terraform {
21
+
required_version = ">= 1.0"
19
22
backend "remote" {
20
23
# ...
21
24
}
@@ -35,24 +38,24 @@ $ tflint
35
38
Warning: terraform.workspace should not be used with a 'remote' backend (terraform_workspace_remote)
Terraform configuration may include the name of the [current workspace](https://www.terraform.io/docs/state/workspaces.html#current-workspace-interpolation) using the `${terraform.workspace}` interpolation sequence. However, when Terraform Cloud workspaces are executing Terraform runs remotely, the Terraform CLI always uses the `default` workspace.
50
+
Terraform configuration may include the name of the [current workspace](https://developer.hashicorp.com/terraform/language/state/workspaces#current-workspace-interpolation) using the `${terraform.workspace}` interpolation sequence. However, when Terraform Cloud workspaces are executing Terraform runs remotely, the Terraform v1.0.x always uses the `default` workspace.
48
51
49
-
The [remote](https://www.terraform.io/docs/backends/types/remote.html) backend is used with Terraform Cloud workspaces. Even if you set a `prefix` in the `workspaces` block, this value will be ignored during remote runs.
52
+
The [remote](https://developer.hashicorp.com/terraform/language/settings/backends/remote) backend is used with Terraform Cloud workspaces. Even if you set a `prefix` in the `workspaces` block, this value will be ignored during remote runs.
50
53
51
-
For more information, see the [`remote` backend workspaces documentation](https://www.terraform.io/docs/backends/types/remote.html#workspaces).
54
+
For more information, see the [`remote` backend workspaces documentation](https://developer.hashicorp.com/terraform/language/settings/backends/remote#workspace-names).
52
55
53
56
## How To Fix
54
57
55
-
Consider adding a variable to your configuration and setting it in each cloud workspace:
58
+
If you still need support for Terarform v1.0.x, consider adding a variable to your configuration and setting it in each cloud workspace:
56
59
57
60
```tf
58
61
variable "workspace" {
@@ -62,3 +65,5 @@ variable "workspace" {
62
65
```
63
66
64
67
You can also name the variable based on what the workspace suffix represents in your configuration (e.g. environment).
68
+
69
+
If you don't need support for Terraform v1.0.x, you can suppress the issue by updating the `required_version` to not contain 1.0.x.
0 commit comments