mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-08 19:18:30 +00:00
Add import support for google_compute_backend_bucket (#736)
* Add import support for google_compute_backend_bucket * Improve docs for consistency
This commit is contained in:
parent
c8d2131294
commit
a6378fc3d4
31
google/import_compute_backend_bucket_test.go
Normal file
31
google/import_compute_backend_bucket_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccComputeBackendBucket_import(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
backendName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||
storageName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeBackendBucketDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeBackendBucket_basic(backendName, storageName),
|
||||
},
|
||||
resource.TestStep{
|
||||
ResourceName: "google_compute_backend_bucket.foobar",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -15,6 +15,10 @@ func resourceComputeBackendBucket() *schema.Resource {
|
|||
Update: resourceComputeBackendBucketUpdate,
|
||||
Delete: resourceComputeBackendBucketDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -111,6 +115,7 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{})
|
|||
return handleNotFoundError(err, d, fmt.Sprintf("Backend Bucket %q", d.Get("name").(string)))
|
||||
}
|
||||
|
||||
d.Set("name", bucket.Name)
|
||||
d.Set("bucket_name", bucket.BucketName)
|
||||
d.Set("description", bucket.Description)
|
||||
d.Set("enable_cdn", bucket.EnableCdn)
|
||||
|
|
|
@ -17,7 +17,7 @@ and
|
|||
## Example Usage
|
||||
|
||||
```hcl
|
||||
resource "google_compute_backend_bucket" "foobar" {
|
||||
resource "google_compute_backend_bucket" "image_backend" {
|
||||
name = "image-backend-bucket"
|
||||
description = "Contains beautiful images"
|
||||
bucket_name = "${google_storage_bucket.image_bucket.name}"
|
||||
|
@ -53,3 +53,11 @@ The following arguments are supported:
|
|||
In addition to the arguments listed above, the following computed attributes are exported:
|
||||
|
||||
* `self_link` - The URI of the created resource.
|
||||
|
||||
## Import
|
||||
|
||||
Backend buckets can be imported using the `name`, e.g.
|
||||
|
||||
```
|
||||
$ terraform import google_compute_backend_bucket.image_backend image-backend-bucket
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user