update the remote state datasource
Add an `environment` field to the terraform remote state data source.
This commit is contained in:
parent
b53704ed87
commit
6c3800d17f
|
@ -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