mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
parent
92fe030b5e
commit
a554f15490
@ -56,6 +56,13 @@ func resourceStorageBucket() *schema.Resource {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"storage_class": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: "STANDARD",
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"website": &schema.Schema{
|
"website": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -91,6 +98,10 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error
|
|||||||
// Create a bucket, setting the acl, location and name.
|
// Create a bucket, setting the acl, location and name.
|
||||||
sb := &storage.Bucket{Name: bucket, Location: location}
|
sb := &storage.Bucket{Name: bucket, Location: location}
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("storage_class"); ok {
|
||||||
|
sb.StorageClass = v.(string)
|
||||||
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("website"); ok {
|
if v, ok := d.GetOk("website"); ok {
|
||||||
websites := v.([]interface{})
|
websites := v.([]interface{})
|
||||||
|
|
||||||
|
@ -59,6 +59,45 @@ func TestAccStorageCustomAttributes(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccStorageStorageClass(t *testing.T) {
|
||||||
|
bucketName := fmt.Sprintf("tf-test-acc-bucket-%d", acctest.RandInt())
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccGoogleStorageDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "STANDARD"),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckCloudStorageBucketExists(
|
||||||
|
"google_storage_bucket.bucket", bucketName),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"google_storage_bucket.bucket", "storage_class", "STANDARD"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "NEARLINE"),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckCloudStorageBucketExists(
|
||||||
|
"google_storage_bucket.bucket", bucketName),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"google_storage_bucket.bucket", "storage_class", "NEARLINE"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "DURABLE_REDUCED_AVAILABILITY"),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckCloudStorageBucketExists(
|
||||||
|
"google_storage_bucket.bucket", bucketName),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"google_storage_bucket.bucket", "storage_class", "DURABLE_REDUCED_AVAILABILITY"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccStorageBucketUpdate(t *testing.T) {
|
func TestAccStorageBucketUpdate(t *testing.T) {
|
||||||
bucketName := fmt.Sprintf("tf-test-acl-bucket-%d", acctest.RandInt())
|
bucketName := fmt.Sprintf("tf-test-acl-bucket-%d", acctest.RandInt())
|
||||||
|
|
||||||
@ -226,3 +265,12 @@ resource "google_storage_bucket" "bucket" {
|
|||||||
}
|
}
|
||||||
`, bucketName)
|
`, bucketName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGoogleStorageBucketsReaderStorageClass(bucketName string, storageClass string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "google_storage_bucket" "bucket" {
|
||||||
|
name = "%s"
|
||||||
|
storage_class = "%s"
|
||||||
|
}
|
||||||
|
`, bucketName, storageClass)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user