provider/terraform: deprecate "environment" in favor of "workspace"
This commit is contained in:
parent
03c123e39d
commit
5c58ef16f7
|
@ -43,6 +43,13 @@ func dataSourceRemoteState() *schema.Resource {
|
|||
},
|
||||
|
||||
"environment": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
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,
|
||||
|
@ -84,9 +91,13 @@ func dataSourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return fmt.Errorf("error initializing backend: %s", err)
|
||||
}
|
||||
|
||||
// Get the state
|
||||
env := d.Get("environment").(string)
|
||||
state, err := b.State(env)
|
||||
// environment is deprecated in favour of workspace.
|
||||
// If both keys are set workspace should win.
|
||||
name := d.Get("environment").(string)
|
||||
if ws, ok := d.GetOk("workspace"); ok {
|
||||
name = ws.(string)
|
||||
}
|
||||
state, err := b.State(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error loading the remote state: %s", err)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ resource "aws_instance" "foo" {
|
|||
The following arguments are supported:
|
||||
|
||||
* `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.
|
||||
* `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)
|
||||
|
|
Loading…
Reference in New Issue