From f65adf03836a368ae35f856229d7cd17cf070a68 Mon Sep 17 00:00:00 2001 From: James Kwon Date: Wed, 3 Apr 2024 18:26:17 -0400 Subject: [PATCH 1/2] condition to allow multi region list only to us-west-2 --- aws/resources/s3_multi_region_access_point.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aws/resources/s3_multi_region_access_point.go b/aws/resources/s3_multi_region_access_point.go index 272b5a30..af6e605e 100644 --- a/aws/resources/s3_multi_region_access_point.go +++ b/aws/resources/s3_multi_region_access_point.go @@ -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") @@ -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) } From f1864247e48d4f5d7a1bfd0c0ee9bd68aad33f35 Mon Sep 17 00:00:00 2001 From: James Kwon Date: Mon, 8 Apr 2024 09:12:03 -0400 Subject: [PATCH 2/2] condition to allow multi region list only to us-west-2 --- aws/resources/s3_multi_region_access_point_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws/resources/s3_multi_region_access_point_test.go b/aws/resources/s3_multi_region_access_point_test.go index 4b1574b3..c3d9effc 100644 --- a/aws/resources/s3_multi_region_access_point_test.go +++ b/aws/resources/s3_multi_region_access_point_test.go @@ -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{ @@ -101,6 +102,7 @@ func TestS3MultiRegionAccessPoint_NukeAll(t *testing.T) { t.Parallel() rc := S3MultiRegionAccessPoint{ + Region: "us-west-2", Client: mockS3MultiRegionAccessPoint{ DeleteMultiRegionAccessPointOutput: s3control.DeleteMultiRegionAccessPointOutput{}, },