Resolving Access Denied Errors in N2WS S3 Sync (CopyObject or ListObjectsV2 )

Resolving Access Denied Errors in N2WS S3 Sync (CopyObject or ListObjectsV2 )

When using N2WS S3 sync policies, you might encounter the following errors:

  • CopyObject Operation Error:

    10/29/2024 03:02:11 PM, Error, "copy failed: s3://atestbucket2022saif/cli commands.txt to s3://s3sync-cross-account-destination/cli commands.txt An error occurred (AccessDenied) when calling the CopyObject operation: Access Denied"
    
    
  • ListObjectsV2 Operation Error:

    10/29/2024 03:22:34 PM, Error, "fatal error: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied"
    
    

Solution:

To resolve these errors, you need to modify the bucket policy to include access to the bucket’s objects. Update your bucket policy as follows:

Original Bucket Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789123:root"
}, "Action": "s3:*", "Resource": [ "arn:aws:s3:::s3sync-cross-account-destination-with-kms" ] } ] }

Updated Bucket Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789123:root"
            },
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::s3sync-cross-account-destination-with-kms",
                "arn:aws:s3:::s3sync-cross-account-destination-with-kms/*"
            ]
        }
    ]
}

Steps to Update the Bucket Policy:

  1. Access the S3 Console:

    • Go to the destination AWS Management Console and open the S3 service.
  2. Navigate to the Bucket:

    • Select the bucket you are syncing to (e.g., s3sync-cross-account-destination-with-kms).
  3. Edit the Bucket Policy:

    • Go to the Permissions tab.
    • Click on Bucket Policy and replace the existing policy with the updated policy shown above.
  4. Save Changes:

    • Save the updated policy to apply the changes.

By updating the bucket policy to include access to the bucket’s objects, you should be able to resolve the Access Denied errors and successfully perform S3 sync operations.

If you need further assistance, feel free to ask!