Skip to content

Commit

Permalink
Fix for issue 4838 (#4840)
Browse files Browse the repository at this point in the history
  • Loading branch information
IBM-diksha authored Oct 4, 2023
1 parent 5bb110d commit dbf1256
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ibm/service/cos/data_source_ibm_cos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,24 +851,21 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error
getBucketWebsiteConfigurationInput := &s3.GetBucketWebsiteInput{
Bucket: aws.String(bucketName),
}

outputBucketWebsite, err := s3Client.GetBucketWebsite(getBucketWebsiteConfigurationInput)
var outputBucketWebsiteptr *s3.WebsiteConfiguration
outputBucketWebsiteptr = (*s3.WebsiteConfiguration)(outputBucketWebsite)
if err != nil && !strings.Contains(err.Error(), "AccessDenied: Access Denied") {
outputwebsite, err := s3Client.GetBucketWebsite(getBucketWebsiteConfigurationInput)
var outputptr *s3.WebsiteConfiguration
outputptr = (*s3.WebsiteConfiguration)(outputwebsite)
if err != nil && !strings.Contains(err.Error(), "AccessDenied: Access Denied") && !strings.Contains(err.Error(), "The specified bucket does not have a website configuration") {
return err
}

if outputBucketWebsite != nil {
websiteConfiguration := flex.WebsiteConfigurationGet(outputBucketWebsiteptr)
if outputwebsite.IndexDocument != nil || outputwebsite.RedirectAllRequestsTo != nil {
websiteConfiguration := flex.WebsiteConfigurationGet(outputptr)
if len(websiteConfiguration) > 0 {
d.Set("website_configuration", websiteConfiguration)
}
websiteEndpoint := getWebsiteEndpoint(bucketName, bucketRegion)
if websiteEndpoint != "" {
d.Set("website_endpoint", websiteEndpoint)
}

}

return nil
Expand Down

0 comments on commit dbf1256

Please sign in to comment.