providers/aws: Test S3 website endpoint attr
This commit is contained in:
parent
87e6d3d17f
commit
2745adba56
|
@ -23,6 +23,8 @@ func TestAccAWSS3Bucket(t *testing.T) {
|
||||||
Config: testAccAWSS3BucketConfig,
|
Config: testAccAWSS3BucketConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_s3_bucket.bucket", "website_endpoint", ""),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -41,6 +43,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
|
||||||
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
testAccCheckAWSS3BucketWebsite(
|
testAccCheckAWSS3BucketWebsite(
|
||||||
"aws_s3_bucket.bucket", "index.html", ""),
|
"aws_s3_bucket.bucket", "index.html", ""),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_s3_bucket.bucket", "website_endpoint", testAccWebsiteEndpoint),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
@ -49,6 +53,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
|
||||||
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
testAccCheckAWSS3BucketWebsite(
|
testAccCheckAWSS3BucketWebsite(
|
||||||
"aws_s3_bucket.bucket", "index.html", "error.html"),
|
"aws_s3_bucket.bucket", "index.html", "error.html"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_s3_bucket.bucket", "website_endpoint", testAccWebsiteEndpoint),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
@ -57,6 +63,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
|
||||||
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
testAccCheckAWSS3BucketWebsite(
|
testAccCheckAWSS3BucketWebsite(
|
||||||
"aws_s3_bucket.bucket", "", ""),
|
"aws_s3_bucket.bucket", "", ""),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_s3_bucket.bucket", "website_endpoint", ""),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -142,13 +150,14 @@ func testAccCheckAWSS3BucketWebsite(n string, indexDoc string, errorDoc string)
|
||||||
|
|
||||||
// These need a bit of randomness as the name can only be used once globally
|
// These need a bit of randomness as the name can only be used once globally
|
||||||
// within AWS
|
// within AWS
|
||||||
var d = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
|
var randInt = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
|
||||||
|
var testAccWebsiteEndpoint = fmt.Sprintf("tf-test-bucket-%d.s3-website-us-east-1.amazonaws.com", randInt)
|
||||||
var testAccAWSS3BucketConfig = fmt.Sprintf(`
|
var testAccAWSS3BucketConfig = fmt.Sprintf(`
|
||||||
resource "aws_s3_bucket" "bucket" {
|
resource "aws_s3_bucket" "bucket" {
|
||||||
bucket = "tf-test-bucket-%d"
|
bucket = "tf-test-bucket-%d"
|
||||||
acl = "public-read"
|
acl = "public-read"
|
||||||
}
|
}
|
||||||
`, d)
|
`, randInt)
|
||||||
|
|
||||||
var testAccAWSS3BucketWebsiteConfig = fmt.Sprintf(`
|
var testAccAWSS3BucketWebsiteConfig = fmt.Sprintf(`
|
||||||
resource "aws_s3_bucket" "bucket" {
|
resource "aws_s3_bucket" "bucket" {
|
||||||
|
@ -159,7 +168,7 @@ resource "aws_s3_bucket" "bucket" {
|
||||||
index_document = "index.html"
|
index_document = "index.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, d)
|
`, randInt)
|
||||||
|
|
||||||
var testAccAWSS3BucketWebsiteConfigWithError = fmt.Sprintf(`
|
var testAccAWSS3BucketWebsiteConfigWithError = fmt.Sprintf(`
|
||||||
resource "aws_s3_bucket" "bucket" {
|
resource "aws_s3_bucket" "bucket" {
|
||||||
|
@ -171,4 +180,4 @@ resource "aws_s3_bucket" "bucket" {
|
||||||
error_document = "error.html"
|
error_document = "error.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, d)
|
`, randInt)
|
||||||
|
|
Loading…
Reference in New Issue