diff --git a/builtin/providers/opc/resource_storage_volume_snapshot.go b/builtin/providers/opc/resource_storage_volume_snapshot.go index 629dc2f3c..5fb0d9847 100644 --- a/builtin/providers/opc/resource_storage_volume_snapshot.go +++ b/builtin/providers/opc/resource_storage_volume_snapshot.go @@ -2,6 +2,7 @@ package opc import ( "fmt" + "strconv" "github.com/hashicorp/go-oracle-terraform/compute" "github.com/hashicorp/terraform/helper/schema" @@ -18,7 +19,7 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource { Schema: map[string]*schema.Schema{ // Required Attributes - "volume": { + "volume_name": { Type: schema.TypeString, Required: true, ForceNew: true, @@ -40,10 +41,10 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource { }, "parent_volume_bootable": { - Type: schema.TypeString, + Type: schema.TypeBool, Optional: true, ForceNew: true, - Default: "false", + Default: false, }, "collocated": { @@ -124,7 +125,7 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa // Get required attribute input := &compute.CreateStorageVolumeSnapshotInput{ - Volume: d.Get("volume").(string), + Volume: d.Get("volume_name").(string), } if v, ok := d.GetOk("description"); ok { @@ -135,8 +136,10 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa input.Name = v.(string) } - if v, ok := d.GetOk("parent_volume_bootable"); ok { - input.ParentVolumeBootable = v.(string) + // Convert parent_volume_bootable to string + bootable := d.Get("parent_volume_bootable").(bool) + if bootable { + input.ParentVolumeBootable = "true" } collocated := d.Get("collocated").(bool) @@ -180,10 +183,9 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface return nil } - d.Set("volume", result.Volume) + d.Set("volume_name", result.Volume) d.Set("description", result.Description) d.Set("name", result.Name) - d.Set("parent_volume_bootable", result.ParentVolumeBootable) d.Set("property", result.Property) d.Set("platform", result.Platform) d.Set("account", result.Account) @@ -197,6 +199,12 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface d.Set("status_timestamp", result.StatusTimestamp) d.Set("uri", result.URI) + bootable, err := strconv.ParseBool(result.ParentVolumeBootable) + if err != nil { + return fmt.Errorf("Error converting parent volume to boolean: %v", err) + } + d.Set("parent_volume_bootable", bootable) + if result.Property != compute.SnapshotPropertyCollocated { d.Set("collocated", false) } else { diff --git a/builtin/providers/opc/resource_storage_volume_snapshot_test.go b/builtin/providers/opc/resource_storage_volume_snapshot_test.go index 9d0c40798..9d4b08ee0 100644 --- a/builtin/providers/opc/resource_storage_volume_snapshot_test.go +++ b/builtin/providers/opc/resource_storage_volume_snapshot_test.go @@ -82,7 +82,7 @@ resource "opc_compute_storage_volume_snapshot" "test" { name = "test-acc-stor-vol-%d" description = "storage volume snapshot" collocated = true - volume = "${opc_compute_storage_volume.foo.name}" + volume_name = "${opc_compute_storage_volume.foo.name}" } `, rInt, rInt) } diff --git a/builtin/providers/opc/resource_storage_volume_test.go b/builtin/providers/opc/resource_storage_volume_test.go index 0c6ec0d90..fc157ef94 100644 --- a/builtin/providers/opc/resource_storage_volume_test.go +++ b/builtin/providers/opc/resource_storage_volume_test.go @@ -238,10 +238,10 @@ resource "opc_compute_storage_volume" "foo" { } resource "opc_compute_storage_volume_snapshot" "foo" { - description = "testing-acc" - name = "test-acc-stor-snapshot-%d" - collocated = true - volume = "${opc_compute_storage_volume.foo.name}" + description = "testing-acc" + name = "test-acc-stor-snapshot-%d" + collocated = true + volume_name = "${opc_compute_storage_volume.foo.name}" } // Create storage volume from snapshot diff --git a/website/source/docs/providers/opc/r/opc_compute_storage_volume_snapshot.html.markdown b/website/source/docs/providers/opc/r/opc_compute_storage_volume_snapshot.html.markdown index f7ba88e06..13ba265a5 100644 --- a/website/source/docs/providers/opc/r/opc_compute_storage_volume_snapshot.html.markdown +++ b/website/source/docs/providers/opc/r/opc_compute_storage_volume_snapshot.html.markdown @@ -18,6 +18,7 @@ resource "opc_compute_storage_volume_snapshot" "test" { description = "Description for the Storage Volume" tags = ["bar", "foo"] collocated = true + volume_name = "${opc_compute_storage_volume.foo.name}" } ``` @@ -25,7 +26,7 @@ resource "opc_compute_storage_volume_snapshot" "test" { The following arguments are supported: -* `volume` (Required) The name of the storage volume to create the snapshot from. +* `volume_name` (Required) The name of the storage volume to create the snapshot from. * `description` (Optional) The description of the storage volume snapshot. * `name` (Optional) The name of the storage volume snapshot. Will be generated if unspecified. * `parent_volume_bootable` (Optional) A string value of whether or not the parent volume is 'bootable' or not. Defaults to `"false"`. diff --git a/website/source/layouts/opc.erb b/website/source/layouts/opc.erb index f27a27e8b..0bc3e3ab4 100644 --- a/website/source/layouts/opc.erb +++ b/website/source/layouts/opc.erb @@ -85,6 +85,9 @@