Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_s3_bucket: Continue supporting empty string bucket argument #7881

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func resourceAwsS3Bucket() *schema.Resource {
Computed: true,
ForceNew: true,
ConflictsWith: []string{"bucket_prefix"},
ValidateFunc: validation.StringLenBetween(3, 63),
ValidateFunc: validation.StringLenBetween(0, 63),
},
"bucket_prefix": {
Type: schema.TypeString,
Expand Down
27 changes: 27 additions & 0 deletions aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ func TestAccAWSS3Bucket_basic(t *testing.T) {
})
}

// Support for common Terraform 0.11 pattern
// Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/7868
func TestAccAWSS3Bucket_Bucket_EmptyString(t *testing.T) {
resourceName := "aws_s3_bucket.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSS3BucketConfigBucketEmptyString,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketExists(resourceName),
resource.TestMatchResourceAttr(resourceName, "bucket", regexp.MustCompile("^terraform-")),
),
},
},
})
}

func TestAccAWSS3MultiBucket_withTags(t *testing.T) {
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -3092,6 +3113,12 @@ resource "aws_s3_bucket" "arbitrary" {
`, randInt)
}

const testAccAWSS3BucketConfigBucketEmptyString = `
resource "aws_s3_bucket" "test" {
bucket = ""
}
`

const testAccAWSS3BucketConfig_namePrefix = `
resource "aws_s3_bucket" "test" {
bucket_prefix = "tf-test-"
Expand Down