provider/aws: Only read S3 bucket policy if it's set
This commit is contained in:
parent
18bd206c38
commit
59a7a5ca27
|
@ -451,21 +451,23 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
// Read the policy
|
||||
pol, err := s3conn.GetBucketPolicy(&s3.GetBucketPolicyInput{
|
||||
Bucket: aws.String(d.Id()),
|
||||
})
|
||||
log.Printf("[DEBUG] S3 bucket: %s, read policy: %v", d.Id(), pol)
|
||||
if err != nil {
|
||||
if err := d.Set("policy", ""); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if v := pol.Policy; v == nil {
|
||||
if _, ok := d.GetOk("policy"); ok {
|
||||
pol, err := s3conn.GetBucketPolicy(&s3.GetBucketPolicyInput{
|
||||
Bucket: aws.String(d.Id()),
|
||||
})
|
||||
log.Printf("[DEBUG] S3 bucket: %s, read policy: %v", d.Id(), pol)
|
||||
if err != nil {
|
||||
if err := d.Set("policy", ""); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := d.Set("policy", normalizeJson(*v)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if v := pol.Policy; v == nil {
|
||||
if err := d.Set("policy", ""); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := d.Set("policy", normalizeJson(*v)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue