mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
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
|
// Read the policy
|
||||||
pol, err := s3conn.GetBucketPolicy(&s3.GetBucketPolicyInput{
|
if _, ok := d.GetOk("policy"); ok {
|
||||||
Bucket: aws.String(d.Id()),
|
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 {
|
log.Printf("[DEBUG] S3 bucket: %s, read policy: %v", d.Id(), pol)
|
||||||
if err := d.Set("policy", ""); err != nil {
|
if err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if v := pol.Policy; v == nil {
|
|
||||||
if err := d.Set("policy", ""); err != nil {
|
if err := d.Set("policy", ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if err := d.Set("policy", normalizeJson(*v)); err != nil {
|
} else {
|
||||||
return err
|
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
Block a user