diff --git a/.changelog/3142.txt b/.changelog/3142.txt new file mode 100644 index 00000000000..3e11c642fbc --- /dev/null +++ b/.changelog/3142.txt @@ -0,0 +1,3 @@ +```release-note:new-datasource +`google_compute_backend_bucket` +``` diff --git a/google/data_source_google_compute_backend_bucket.go b/google/data_source_google_compute_backend_bucket.go index 94c6ebf9954..8c68e8b4c1c 100644 --- a/google/data_source_google_compute_backend_bucket.go +++ b/google/data_source_google_compute_backend_bucket.go @@ -24,14 +24,14 @@ func dataSourceGoogleComputeBackendBucket() *schema.Resource { func dataSourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - serviceName := d.Get("name").(string) + backendBucketName := d.Get("name").(string) project, err := getProject(d, config) if err != nil { return err } - d.SetId(fmt.Sprintf("projects/%s/global/backendBuckets/%s", project, serviceName)) + d.SetId(fmt.Sprintf("projects/%s/global/backendBuckets/%s", project, backendBucketName)) return resourceComputeBackendBucketRead(d, meta) } diff --git a/google/data_source_google_compute_backend_bucket_test.go b/google/data_source_google_compute_backend_bucket_test.go index 6b729f2e091..8082193794b 100644 --- a/google/data_source_google_compute_backend_bucket_test.go +++ b/google/data_source_google_compute_backend_bucket_test.go @@ -11,7 +11,7 @@ import ( func TestAccDataSourceComputeBackendBucket_basic(t *testing.T) { t.Parallel() - serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) + backendBucketName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) bucketName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ @@ -20,14 +20,14 @@ func TestAccDataSourceComputeBackendBucket_basic(t *testing.T) { CheckDestroy: testAccCheckComputeBackendBucketDestroy, Steps: []resource.TestStep{ { - Config: testAccDataSourceComputeBackendBucket_basic(serviceName, bucketName), + Config: testAccDataSourceComputeBackendBucket_basic(backendBucketName, bucketName), Check: checkDataSourceStateMatchesResourceState("data.google_compute_backend_bucket.baz", "google_compute_backend_bucket.foobar"), }, }, }) } -func testAccDataSourceComputeBackendBucket_basic(serviceName, bucketName string) string { +func testAccDataSourceComputeBackendBucket_basic(backendBucketName, bucketName string) string { return fmt.Sprintf(` resource "google_compute_backend_bucket" "foobar" { name = "%s" @@ -35,14 +35,12 @@ resource "google_compute_backend_bucket" "foobar" { bucket_name = google_storage_bucket.image_bucket.name enable_cdn = true } - resource "google_storage_bucket" "image_bucket" { name = "%s" location = "EU" } - data "google_compute_backend_bucket" "baz" { name = google_compute_backend_bucket.foobar.name } -`, serviceName, bucketName) +`, backendBucketName, bucketName) } diff --git a/google/provider.go b/google/provider.go index 70798db2f39..a776b1e9462 100644 --- a/google/provider.go +++ b/google/provider.go @@ -435,8 +435,8 @@ func Provider() terraform.ResourceProvider { "google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(), "google_composer_image_versions": dataSourceGoogleComposerImageVersions(), "google_compute_address": dataSourceGoogleComputeAddress(), - "google_compute_backend_bucket": dataSourceGoogleComputeBackendBucket(), "google_compute_backend_service": dataSourceGoogleComputeBackendService(), + "google_compute_backend_bucket": dataSourceGoogleComputeBackendBucket(), "google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(), "google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(), "google_compute_global_address": dataSourceGoogleComputeGlobalAddress(), diff --git a/website/docs/d/datasource_google_compute_backend_bucket.html.markdown b/website/docs/d/datasource_google_compute_backend_bucket.html.markdown new file mode 100644 index 00000000000..68b71399124 --- /dev/null +++ b/website/docs/d/datasource_google_compute_backend_bucket.html.markdown @@ -0,0 +1,53 @@ +--- +subcategory: "Compute Engine" +layout: "google" +page_title: "Google: google_compute_backend_bucket" +sidebar_current: "docs-google-datasource-compute-backend-bucket" +description: |- + Get information about a BackendBucket. +--- + +# google\_compute\_backend\_bucket + +Get information about a BackendBucket. + +## Example Usage + +```tf +data "google_compute_backend_bucket" "my-backend-bucket" { + name = "my-backend" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Name of the resource. + +- - - + +* `project` - (Optional) The ID of the project in which the resource belongs. If it + is not provided, the provider project is used. + +## Attributes Reference + +In addition to the arguments listed above, the following attributes are exported: + +* `bucket_name` - Cloud Storage bucket name. + +* `cdn_policy` - Cloud CDN configuration for this Backend Bucket. Structure is documented below. + +* `description` - An optional textual description of the resource; provided by the client when the resource is created. + +* `enable_cdn` - Whether Cloud CDN is enabled for this BackendBucket. + +* `id` - an identifier for the resource with format `projects/{{project}}/global/backendBuckets/{{name}}` + +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + +* `self_link` - The URI of the created resource. + +The `cdn_policy` block supports: + +* `signed_url_cache_max_age_sec` - Maximum number of seconds the response to a signed URL request will be considered fresh. After this time period, the response will be revalidated before being served. When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered. diff --git a/website/google.erb b/website/google.erb index 949283768e6..c50ebf48b4c 100644 --- a/website/google.erb +++ b/website/google.erb @@ -57,6 +57,9 @@