Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
Boto3: Using boto3.resource('s3') to list all S3 buckets

Is it possible to list all S3 buckets using a boto3 resource, ie boto3.resource('s3')?

I know that it's possible to do so using a low-level service client:

import boto3
boto3.client('s3').list_buckets()

However in an ideal world we can operate at the higher level of resources. Is there a method that allows us to to do and, if not, why?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can use s3.buckets.all():

s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
  print(bucket.name)

Using list comprehension:

s3 = boto3.resource('s3')
buckets = [bucket.name for bucket in s3.buckets.all()]
print(buckets)
over 4 years ago · Santiago Trujillo Relatório

0

Get .buckets.pages() from the S3 resource and then loop through the pages to grab the buckets:

import boto3


buckets_iter = boto3.resource('s3').buckets.pages()
buckets = []
for bucket in buckets_iter:
    buckets += bucket

print(buckets)

I hope this helps.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda