0
votes

I have S3 bucket called "atest-bucket". Inside of this bucket I have directory named "data". I need to provide access to user from external account to this directory (this user will access my data in order to run AWS ElasticMapReduce job).

With the policy I created, user still getting 403, when trying access it:

Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;

Here is my policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AccessToDataFiles",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::11111111111:user/emr",
                   "arn:aws:iam::11111111111:role/EMR_EC2_DefaultRole"
                ]
            },
            "Action": "s3:List*",
            "Resource": "arn:aws:s3:::atest-bucket/data"
        },
        {
            "Sid": "Stmt1234456",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::11111111111:user/emr",
                   "arn:aws:iam::11111111111:role/EMR_EC2_DefaultRole"
                ]
            },
            "Action": [
                "s3:Get*",
                "s3:List*",
                "s3:Put*"
            ],
            "Resource": "arn:aws:s3:::atest-bucket/data/*"
        }
    ]
}

Please help me investigate this issue.

1
When you say "when trying access it", what specific command did you use? Also, what S3-related permissions does the user/role in the other account have? (They need permission to call S3 granted by their own account AND they need permission via the Bucket Policy.)John Rotenstein

1 Answers

1
votes

I believe you granted permission for another account(111----------). In this account you need to delegate further permission to specific user that you are using. You need to delegate permission to your user for accessing the bucket created by previous account.

Create inline policy for the user in account(111----------):

{ "Version": "2012-10-17", "Statement": [ { "Sid": "Example", "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::examplebucket" ] } ] }

Please refer the following url: https://docs.aws.amazon.com/AmazonS3/latest/dev/example-walkthroughs-managing-access-example2.html