Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Make all keys in s3 bucket private

I have a bucket with 10^6 keys in it. I want to make all objects in it private.

I tried s3cmd which fails after sometime. I tried it with boto3, but it is painfully slow.

import boto3

boto3.setup_default_session(aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)
s3_client = boto3.client('s3')
s3_resource = boto3.resource('s3')

bucket = s3_resource.Bucket(bucket_name)
bucket_acl = bucket.Acl()

i = 0

for object_summary in bucket.objects.all():
    i += 1
    object_acl = object_summary.Acl()
    if i % 100 == 1:
        print('{} {}'.format(i, object_summary.key))

    object_acl.put(ACL='private')

Is there any way to do batch operation or do everything private by setting some bucket policy.

Any other suggestion is also welcome.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Unfortunately i did not find a good solution. I decided to run it for 70 hours with nohup in background.

A possible solution I thought was to split keys in bucket into multiple sets and run them using multiple threads.

But in the end I just waited 70 hours.

about 4 years ago · Santiago Trujillo Report

0

You don't need to do anything. Objects in Amazon S3 are private by default.

Things that make them public are:

  • Bucket Polices on the bucket containing the objects
  • Permissions granted to Users, Groups and Roles in Amazon IAM
  • Permissions applied specifically to each object ("ACLs")
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!