Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change for the issue 4838 - ibm_cos_bucket data lookup is throwing NoSuchWebsiteConfiguration #4840

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputBucketWebsite != nil also do we needto check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of outputBucketWebsite != nil I am checking outputwebsite.IndexDocument != nil . because outputBucketwebsite is returned empty when no website configuration {} so the outputBucketWebsite != nil check was passing which we don't want.

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
Loading