diff --git a/data_source_state.go b/data_source_state.go index ee9a63630..730158550 100644 --- a/data_source_state.go +++ b/data_source_state.go @@ -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) }