MKG
MKG

Reputation: 371

What minimum permissions should I set to give S3 file upload access?

I used HTML and Javascript to upload a file on S3. I am facing a problem --> I created a role for unauthenticated entities and assigned the following policy to it.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:putObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name/*"
            ]
        }
    ]
}

I get an access denied error.But when I give the permission as

"s3:*" I am able to upload the file. What minimum permissions can I give to make this work

Upvotes: 11

Views: 10778

Answers (2)

Muhammad Abdullah
Muhammad Abdullah

Reputation: 4535

For Delete and Upload, we can use permission

    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObjectAcl",
                "s3:DeleteObjectVersion",
                "s3:ListBucket",
                "s3:DeleteObject",
                "s3:GetBucketLocation",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::BUCKET_NAME/*",
                "arn:aws:s3:::BUCKET_NAME"
            ]
        }
    ]
}

Upvotes: 4

HMT
HMT

Reputation: 2271

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObjectAcl",
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": "arn:aws:s3:::bucket-name/*"
        }
    ]
}

Upvotes: 14

Related Questions