feat(s3): S3_002: check bucket has no replication to other region #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #5
Replacing the
AWS_S3_002
checkThis PR replaces the check
AWS_S3_002
"S3 buckets are not global but in one zone" because it was inaccurate (see #5).The new check is "S3 buckets are not replicated to another region". It checks the bucket replication configuration if at least one replication rule has a destination bucket in another region than the current bucket.
Test
Context:
.yatas.yml
, one per region :Setup:
Run YATAS on your setup (including only the
AWS_S3_002
check):Implementation details
This PR adds the
GetS3ToReplicationOtherRegion
getter to S3 package which iterates over the bucket of the current region (passed by parameters) and check if a replication configuration is enabled on the bucket and if so, if a replication rule replicates to a bucket which is in another region.yatas-aws/aws/s3/getter.go
Line 170 in 4fcedd4
In order for this implementation to work I had to slightly modify the
CheckS3Location
function to return also the region of the bucket that is compared.I also fixed a bug that was unknown to this day: if the bucket was in the
us-east-1
region, the function was always returningfalse
. This is because, for theus-east-1
region, the AWS API returns a LocationConstraint ofnull
(empty string in Go). A new check is therefore implemented:yatas-aws/aws/s3/s3.go
Lines 26 to 36 in 4fcedd4