DEV Community

Srinivasulu Paranduru
Srinivasulu Paranduru

Posted on

S3 Sync cross account

1.Attach the policy to Source S3 bucket

{
        "Sid": "CrossAccountSyncAccess",
        "Effect": "Allow",
        "Principal": {"AWS": "destination account"},
        "Action" : [ "s3:ListBucket","s3:GetObject"],
        "Resource" :[
            "arn:aws:s3:::Source-Bucket-Name/*",
            "arn:aws:s3:::Source-Bucket-Name"
        ]
}
Enter fullscreen mode Exit fullscreen mode
  1. Attach the below iam policy for destination account - EC2 Instance profile role
{
        "Sid": "CrossAccountSyncAccess_Source",
        "Effect": "Allow",
        "Action" : [ "s3:ListBucket","s3:GetObject"],
        "Resource" :[
            "arn:aws:s3:::Source-Bucket-Name/*",
            "arn:aws:s3:::Source-Bucket-Name"
        ]
},
{
        "Sid": "CrossAccountSyncAccess_Destination",
        "Effect": "Allow",
        "Action" : [ "s3:ListBucket","s3:PutObject","s3:PutObjectAcl"],
        "Resource" :[
            "arn:aws:s3:::Destination-Bucket-Name/*",
            "arn:aws:s3:::Destination-Bucket-Name"
        ]
}

3. Run the below command

Enter fullscreen mode Exit fullscreen mode

aws s3 sync s3://Source-BucketName s3://Destination-BucketName


Enter fullscreen mode Exit fullscreen mode

Top comments (0)