Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What permission is needed to use S3 listObjectVersions in AWS?

I currently have a lambda that uses the node sdk call listObjectVersions to list all the versions of a specific file. However, I can't figure out what permission in my policy will grant the lambda permission to make this call. I've searched the AWS documentation and I can not find any information.

Here are the current permissions in my policy:

- PolicyName: S3Policy
  PolicyDocument:
    Version: 2012-10-17
    Statement:
      - Effect: Allow
        Action:
          - s3:PutObject
          - s3:PutObjectAcl
          - s3:GetObject
          - s3:GetObjectVersion
          - s3:ListObjectVersions
          - s3:DeleteObject
          - s3:ListBucket

When I execute the lambda I get an Access Denied when making the call. I've changed my policy to allow the action s3:* and the lambda works. However, I do not want to grant full access to s3.

What Action do I need to add to allow?

like image 993
Gary Holiday Avatar asked Aug 30 '19 19:08

Gary Holiday


People also ask

What permissions are needed for AWS S3 sync?

To run the command aws s3 sync, then you need permission to s3:GetObject, s3:PutObject, and s3:ListBucket. Note: If you're using the AssumeRole API operation to access Amazon S3, you must also verify that the trust relationship is configured correctly.

Is Listobjectversions supported by your bucket?

To use this operation, you must have READ access to the bucket. This action is not supported by Amazon S3 on Outposts.

Which S3 bucket feature must be enabled to allow cross region replication?

Amazon S3 SRR is an S3 feature that automatically replicates data between buckets within the same AWS Region. With SRR, you can set up replication at a bucket level, a shared prefix level, or an object level using S3 object tags. You can use SRR to make one or more copies of your data in the same AWS Region.

What permissions do you set for a bucket in S3 to host a static website?

When you configure a bucket as a static website, if you want your website to be public, you can grant public read access. To make your bucket publicly readable, you must disable block public access settings for the bucket and write a bucket policy that grants public read access.

How do I control access to S3 resources?

Restrict access to your S3 resources. By default, all S3 buckets are private and can be accessed only by users who are explicitly granted access. Restrict access to your S3 buckets or objects by doing the following: Writing IAM user policies that specify the users that can access specific buckets and objects.


1 Answers

From Actions, Resources, and Condition Keys for Amazon S3 - AWS Identity and Access Management:

ListBucketVersions: Use the versions subresource to list metadata about all of the versions of objects in a bucket.

I tested this as follows:

  • Created an IAM User
  • Assigned the policy below
  • Ran the command: aws s3api list-object-versions --bucket my-bucket

It worked successfully.

The policy was:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:ListBucketVersions",
            "Resource": "*"
        }
    ]
}

So, while the naming seems a bit strange (List Object Versions vs List Bucket Versions), it is the correct permission to use.

like image 134
John Rotenstein Avatar answered Oct 05 '22 19:10

John Rotenstein