mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
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"
|
||||
"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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user