diff --git a/google/resource_storage_bucket.go b/google/resource_storage_bucket.go index dd911632..f58a5785 100644 --- a/google/resource_storage_bucket.go +++ b/google/resource_storage_bucket.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "log" + "strings" "time" "github.com/hashicorp/terraform/helper/resource" @@ -11,7 +12,6 @@ import ( "google.golang.org/api/googleapi" "google.golang.org/api/storage/v1" - "strings" ) func resourceStorageBucket() *schema.Resource { @@ -42,8 +42,8 @@ func resourceStorageBucket() *schema.Resource { Default: "US", Optional: true, ForceNew: true, - StateFunc: func(l interface{}) string { - return strings.ToUpper(l.(string)) + StateFunc: func(s interface{}) string { + return strings.ToUpper(s.(string)) }, }, diff --git a/google/resource_storage_bucket_test.go b/google/resource_storage_bucket_test.go index cc051804..d1055a00 100644 --- a/google/resource_storage_bucket_test.go +++ b/google/resource_storage_bucket_test.go @@ -38,6 +38,26 @@ func TestAccStorageBucket_basic(t *testing.T) { }) } +func TestAccStorageBucket_lowercaseLocation(t *testing.T) { + var bucket storage.Bucket + bucketName := fmt.Sprintf("tf-test-acl-bucket-%d", acctest.RandInt()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccStorageBucketDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccStorageBucket_lowercaseLocation(bucketName), + Check: resource.ComposeTestCheckFunc( + testAccCheckStorageBucketExists( + "google_storage_bucket.bucket", bucketName, &bucket), + ), + }, + }, + }) +} + func TestAccStorageBucket_customAttributes(t *testing.T) { var bucket storage.Bucket bucketName := fmt.Sprintf("tf-test-acl-bucket-%d", acctest.RandInt()) @@ -335,6 +355,15 @@ resource "google_storage_bucket" "bucket" { `, bucketName) } +func testAccStorageBucket_lowercaseLocation(bucketName string) string { + return fmt.Sprintf(` +resource "google_storage_bucket" "bucket" { + name = "%s" + location = "eu" +} +`, bucketName) +} + func testAccStorageBucket_customAttributes(bucketName string) string { return fmt.Sprintf(` resource "google_storage_bucket" "bucket" {