diff --git a/ibm/service/cos/data_source_ibm_cos_bucket.go b/ibm/service/cos/data_source_ibm_cos_bucket.go index 0af4dccfed..e45744b986 100644 --- a/ibm/service/cos/data_source_ibm_cos_bucket.go +++ b/ibm/service/cos/data_source_ibm_cos_bucket.go @@ -851,16 +851,14 @@ 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) } @@ -868,7 +866,6 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error if websiteEndpoint != "" { d.Set("website_endpoint", websiteEndpoint) } - } return nil