mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
![]() |
package google
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||
|
"github.com/hashicorp/terraform/helper/resource"
|
||
|
)
|
||
|
|
||
|
func TestAccComputeResourceUsageExportBucket(t *testing.T) {
|
||
|
org := getTestOrgFromEnv(t)
|
||
|
billingId := getTestBillingAccountFromEnv(t)
|
||
|
|
||
|
baseProject := "ub-" + acctest.RandString(10)
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
Steps: []resource.TestStep{
|
||
|
resource.TestStep{
|
||
|
Config: testAccResourceUsageExportBucket(baseProject, org, billingId),
|
||
|
},
|
||
|
// Test import.
|
||
|
resource.TestStep{
|
||
|
ResourceName: "google_project_usage_export_bucket.ueb",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccResourceUsageExportBucket(baseProject, org, billingId string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_project" "base" {
|
||
|
project_id = "%s"
|
||
|
name = "Export Bucket Base"
|
||
|
org_id = "%s"
|
||
|
billing_account = "%s"
|
||
|
}
|
||
|
|
||
|
resource "google_project_service" "service" {
|
||
|
project = "${google_project.base.project_id}"
|
||
|
service = "compute.googleapis.com"
|
||
|
}
|
||
|
|
||
|
resource "google_storage_bucket" "bucket" {
|
||
|
name = "b-${google_project.base.project_id}"
|
||
|
project = "${google_project_service.service.project}"
|
||
|
}
|
||
|
|
||
|
resource "google_project_usage_export_bucket" "ueb" {
|
||
|
project = "${google_project.base.project_id}"
|
||
|
bucket_name = "${google_storage_bucket.bucket.name}"
|
||
|
prefix = "foobar"
|
||
|
}
|
||
|
`, baseProject, org, billingId)
|
||
|
}
|