Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
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.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

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.

over 4 years ago · Santiago Trujillo Denunciar

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")
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda