update the remote state datasource

Add an `environment` field to the terraform remote state data source.
This commit is contained in:
James Bardin 2017-02-28 16:25:42 -05:00
parent 264d3c2808
commit e33310b494
1 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"log"
"time"
"github.com/hashicorp/terraform/backend"
backendinit "github.com/hashicorp/terraform/backend/init"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/schema"
@ -36,6 +37,12 @@ func dataSourceRemoteState() *schema.Resource {
Optional: true,
},
"environment": {
Type: schema.TypeString,
Optional: true,
Default: backend.DefaultStateName,
},
"__has_dynamic_attributes": {
Type: schema.TypeString,
Optional: true,
@ -73,7 +80,8 @@ func dataSourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error {
}
// Get the state
state, err := b.State()
env := d.Get("environment").(string)
state, err := b.State(env)
if err != nil {
return fmt.Errorf("error loading the remote state: %s", err)
}