providers/aws: Fix S3 website error doc
This commit is contained in:
parent
0b78a71ed5
commit
87e6d3d17f
|
@ -129,10 +129,15 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
})
|
})
|
||||||
var websites []map[string]interface{}
|
var websites []map[string]interface{}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
websites = append(websites, map[string]interface{}{
|
w := make(map[string]interface{})
|
||||||
"index_document": *ws.IndexDocument.Suffix,
|
|
||||||
"error_document": *ws.ErrorDocument.Key,
|
w["index_document"] = *ws.IndexDocument.Suffix
|
||||||
})
|
|
||||||
|
if v := ws.ErrorDocument; v != nil {
|
||||||
|
w["error_document"] = *v.Key
|
||||||
|
}
|
||||||
|
|
||||||
|
websites = append(websites, w)
|
||||||
}
|
}
|
||||||
if err := d.Set("website", websites); err != nil {
|
if err := d.Set("website", websites); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -37,6 +37,14 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAWSS3BucketWebsiteConfig,
|
Config: testAccAWSS3BucketWebsiteConfig,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
|
testAccCheckAWSS3BucketWebsite(
|
||||||
|
"aws_s3_bucket.bucket", "index.html", ""),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSS3BucketWebsiteConfigWithError,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
|
||||||
testAccCheckAWSS3BucketWebsite(
|
testAccCheckAWSS3BucketWebsite(
|
||||||
|
@ -118,9 +126,15 @@ func testAccCheckAWSS3BucketWebsite(n string, indexDoc string, errorDoc string)
|
||||||
return fmt.Errorf("bad: %s", out.IndexDocument)
|
return fmt.Errorf("bad: %s", out.IndexDocument)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *out.ErrorDocument.Key != errorDoc {
|
if v := out.ErrorDocument; v == nil {
|
||||||
|
if errorDoc != "" {
|
||||||
return fmt.Errorf("bad: %s", out.ErrorDocument)
|
return fmt.Errorf("bad: %s", out.ErrorDocument)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if *v.Key != errorDoc {
|
||||||
|
return fmt.Errorf("bad: %s", out.ErrorDocument)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -141,6 +155,17 @@ resource "aws_s3_bucket" "bucket" {
|
||||||
bucket = "tf-test-bucket-%d"
|
bucket = "tf-test-bucket-%d"
|
||||||
acl = "public-read"
|
acl = "public-read"
|
||||||
|
|
||||||
|
website {
|
||||||
|
index_document = "index.html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, d)
|
||||||
|
|
||||||
|
var testAccAWSS3BucketWebsiteConfigWithError = fmt.Sprintf(`
|
||||||
|
resource "aws_s3_bucket" "bucket" {
|
||||||
|
bucket = "tf-test-bucket-%d"
|
||||||
|
acl = "public-read"
|
||||||
|
|
||||||
website {
|
website {
|
||||||
index_document = "index.html"
|
index_document = "index.html"
|
||||||
error_document = "error.html"
|
error_document = "error.html"
|
||||||
|
|
Loading…
Reference in New Issue