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

condition to allow multi region list only to us-west-2 #671

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions aws/resources/s3_multi_region_access_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import (
)

func (ap *S3MultiRegionAccessPoint) getAll(c context.Context, configObj config.Config) ([]*string, error) {
// NOTE: All control plane requests to create or maintain Multi-Region Access Points must be routed to the US West (Oregon) Region.
// Reference: https://docs.aws.amazon.com/AmazonS3/latest/userguide/MultiRegionAccessPointRestrictions.html
//
// To avoid receiving the error `PermanentRedirect: This API operation is only available in the following Regions: us-west-2. Make sure to send all future requests to a supported Region`,
// we must ensure that the region is set to us-west-2.
if ap.Region != "us-west-2" {
logging.Debugf("Listing Multi-Region Access Points is only available in the following Region: us-west-2.")
return nil, nil
}

accountID, ok := c.Value(util.AccountIdKey).(string)
if !ok {
logging.Errorf("unable to read the account-id from context")
Expand All @@ -37,6 +47,7 @@ func (ap *S3MultiRegionAccessPoint) getAll(c context.Context, configObj config.C
}
return !lastPage
})

if err != nil {
logging.Errorf("[FAILED] Multi region access point listing - %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions aws/resources/s3_multi_region_access_point_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestS3MultiRegionAccessPoint_GetAll(t *testing.T) {
now := time.Now()

ap := S3MultiRegionAccessPoint{
Region: "us-west-2",
Client: mockS3MultiRegionAccessPoint{
ListMultiRegionAccessPointsOutput: s3control.ListMultiRegionAccessPointsOutput{
AccessPoints: []*s3control.MultiRegionAccessPointReport{
Expand Down Expand Up @@ -101,6 +102,7 @@ func TestS3MultiRegionAccessPoint_NukeAll(t *testing.T) {
t.Parallel()

rc := S3MultiRegionAccessPoint{
Region: "us-west-2",
Client: mockS3MultiRegionAccessPoint{
DeleteMultiRegionAccessPointOutput: s3control.DeleteMultiRegionAccessPointOutput{},
},
Expand Down