providers/aws: Add S3 error_document
Also fix when index/error document is empty
This commit is contained in:
parent
e6d9dcfb1a
commit
b7a9ef5ef6
|
@ -44,6 +44,12 @@ func resourceAwsS3Bucket() *schema.Resource {
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"error_document": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: false,
|
||||||
|
},
|
||||||
|
|
||||||
"tags": tagsSchema(),
|
"tags": tagsSchema(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -141,20 +147,27 @@ func updateWebsite(s3conn *s3.S3, d *schema.ResourceData) error {
|
||||||
website := d.Get("website").(bool)
|
website := d.Get("website").(bool)
|
||||||
bucket := d.Get("bucket").(string)
|
bucket := d.Get("bucket").(string)
|
||||||
indexDocument := d.Get("index_document").(string)
|
indexDocument := d.Get("index_document").(string)
|
||||||
|
errorDocument := d.Get("error_document").(string)
|
||||||
websiteConfiguration := &s3.WebsiteConfiguration{
|
|
||||||
IndexDocument: &s3.IndexDocument{Suffix: aws.String(indexDocument)},
|
|
||||||
}
|
|
||||||
|
|
||||||
if website {
|
if website {
|
||||||
input := &s3.PutBucketWebsiteInput{
|
websiteConfiguration := &s3.WebsiteConfiguration{}
|
||||||
|
|
||||||
|
if indexDocument != "" {
|
||||||
|
websiteConfiguration.IndexDocument = &s3.IndexDocument{Suffix: aws.String(indexDocument)}
|
||||||
|
}
|
||||||
|
|
||||||
|
if errorDocument != "" {
|
||||||
|
websiteConfiguration.ErrorDocument = &s3.ErrorDocument{Key: aws.String(errorDocument)}
|
||||||
|
}
|
||||||
|
|
||||||
|
putInput := &s3.PutBucketWebsiteInput{
|
||||||
Bucket: aws.String(bucket),
|
Bucket: aws.String(bucket),
|
||||||
WebsiteConfiguration: websiteConfiguration,
|
WebsiteConfiguration: websiteConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] S3 put bucket website: %s", input)
|
log.Printf("[DEBUG] S3 put bucket website: %s", putInput)
|
||||||
|
|
||||||
_, err := s3conn.PutBucketWebsite(input)
|
_, err := s3conn.PutBucketWebsite(putInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error putting S3 website: %s", err)
|
return fmt.Errorf("Error putting S3 website: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue