providers/terraform: name it terraform_remote_state

This commit is contained in:
Mitchell Hashimoto 2015-04-01 22:49:05 -07:00
parent 693f688b49
commit 5a6766b702
3 changed files with 17 additions and 12 deletions

View File

@ -9,7 +9,7 @@ import (
func Provider() terraform.ResourceProvider {
return &schema.Provider{
ResourcesMap: map[string]*schema.Resource{
"terraform_state": resourceState(),
"terraform_remote_state": resourceRemoteState(),
},
}
}

View File

@ -8,11 +8,11 @@ import (
"github.com/hashicorp/terraform/state/remote"
)
func resourceState() *schema.Resource {
func resourceRemoteState() *schema.Resource {
return &schema.Resource{
Create: resourceStateCreate,
Read: resourceStateRead,
Delete: resourceStateDelete,
Create: resourceRemoteStateCreate,
Read: resourceRemoteStateRead,
Delete: resourceRemoteStateDelete,
Schema: map[string]*schema.Schema{
"backend": &schema.Schema{
@ -35,11 +35,11 @@ func resourceState() *schema.Resource {
}
}
func resourceStateCreate(d *schema.ResourceData, meta interface{}) error {
return resourceStateRead(d, meta)
func resourceRemoteStateCreate(d *schema.ResourceData, meta interface{}) error {
return resourceRemoteStateRead(d, meta)
}
func resourceStateRead(d *schema.ResourceData, meta interface{}) error {
func resourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error {
backend := d.Get("backend").(string)
config := make(map[string]string)
for k, v := range d.Get("config").(map[string]interface{}) {
@ -60,12 +60,17 @@ func resourceStateRead(d *schema.ResourceData, meta interface{}) error {
return err
}
var outputs map[string]string
if !state.State().Empty() {
outputs = state.State().RootModule().Outputs
}
d.SetId(time.Now().UTC().String())
d.Set("output", state.State().RootModule().Outputs)
d.Set("output", outputs)
return nil
}
func resourceStateDelete(d *schema.ResourceData, meta interface{}) error {
func resourceRemoteStateDelete(d *schema.ResourceData, meta interface{}) error {
d.SetId("")
return nil
}

View File

@ -17,7 +17,7 @@ func TestAccState_basic(t *testing.T) {
Config: testAccState_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckStateValue(
"terraform_state.foo", "foo", "bar"),
"terraform_remote_state.foo", "foo", "bar"),
),
},
},
@ -45,7 +45,7 @@ func testAccCheckStateValue(id, name, value string) resource.TestCheckFunc {
}
const testAccState_basic = `
resource "terraform_state" "foo" {
resource "terraform_remote_state" "foo" {
backend = "_local"
config {