mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/terraform: deprecate "environment" in favor of "workspace"
This commit is contained in:
parent
03c123e39d
commit
5c58ef16f7
@ -46,6 +46,13 @@ func dataSourceRemoteState() *schema.Resource {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: backend.DefaultStateName,
|
Default: backend.DefaultStateName,
|
||||||
|
Deprecated: "Terraform environments are now called workspaces. Please use the workspace key instead.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"workspace": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: backend.DefaultStateName,
|
||||||
},
|
},
|
||||||
|
|
||||||
"__has_dynamic_attributes": {
|
"__has_dynamic_attributes": {
|
||||||
@ -84,9 +91,13 @@ func dataSourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
return fmt.Errorf("error initializing backend: %s", err)
|
return fmt.Errorf("error initializing backend: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the state
|
// environment is deprecated in favour of workspace.
|
||||||
env := d.Get("environment").(string)
|
// If both keys are set workspace should win.
|
||||||
state, err := b.State(env)
|
name := d.Get("environment").(string)
|
||||||
|
if ws, ok := d.GetOk("workspace"); ok {
|
||||||
|
name = ws.(string)
|
||||||
|
}
|
||||||
|
state, err := b.State(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error loading the remote state: %s", err)
|
return fmt.Errorf("error loading the remote state: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ resource "aws_instance" "foo" {
|
|||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `backend` - (Required) The remote backend to use.
|
* `backend` - (Required) The remote backend to use.
|
||||||
* `environment` - (Optional) The Terraform environment to use.
|
* `workspace` - (Optional) The Terraform workspace to use.
|
||||||
* `config` - (Optional) The configuration of the remote backend.
|
* `config` - (Optional) The configuration of the remote backend.
|
||||||
* `defaults` - (Optional) default value for outputs in case state file is empty or it does not have the output.
|
* `defaults` - (Optional) default value for outputs in case state file is empty or it does not have the output.
|
||||||
* Remote state config docs can be found [here](/docs/backends/types/terraform-enterprise.html)
|
* Remote state config docs can be found [here](/docs/backends/types/terraform-enterprise.html)
|
||||||
|
Loading…
Reference in New Issue
Block a user