update the remote state datasource
Add an `environment` field to the terraform remote state data source.
This commit is contained in:
parent
264d3c2808
commit
e33310b494
|
@ -5,6 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/backend"
|
||||||
backendinit "github.com/hashicorp/terraform/backend/init"
|
backendinit "github.com/hashicorp/terraform/backend/init"
|
||||||
"github.com/hashicorp/terraform/config"
|
"github.com/hashicorp/terraform/config"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
@ -36,6 +37,12 @@ func dataSourceRemoteState() *schema.Resource {
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"environment": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: backend.DefaultStateName,
|
||||||
|
},
|
||||||
|
|
||||||
"__has_dynamic_attributes": {
|
"__has_dynamic_attributes": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -73,7 +80,8 @@ func dataSourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the state
|
// Get the state
|
||||||
state, err := b.State()
|
env := d.Get("environment").(string)
|
||||||
|
state, err := b.State(env)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue