Explorando buckets

Introdução ao AWS Boto em Python

Maksim Pecherskiy

Data Engineer

Componentes do S3 - Buckets

  • Pastas do desktop
  • Política de permissão própria
  • Armazenamento de site
  • Gerar logs

Bucket

Introdução ao AWS Boto em Python

Componentes do S3 - Objetos

Objetos em buckets

Introdução ao AWS Boto em Python

O que dá para fazer com buckets?

  • Create Bucket
  • List Buckets
  • Delete Bucket

Bucket

Introdução ao AWS Boto em Python

Criando um bucket

Criar cliente boto3

import boto3
s3 = boto3.client('s3', region_name='us-east-1', 
                         aws_access_key_id=AWS_KEY_ID, 
                         aws_secret_access_key=AWS_SECRET)

Criar bucket!

bucket = s3.create_bucket(Bucket='gid-requests')
Introdução ao AWS Boto em Python

Bang!

Bang bucket!

Introdução ao AWS Boto em Python

Nosso bucket no console

Bucket no console

Introdução ao AWS Boto em Python

Listando buckets

Criar cliente boto3

import boto3
s3 = boto3.client('s3', region_name='us-east-1', 
                         aws_access_key_id=AWS_KEY_ID, 
                         aws_secret_access_key=AWS_SECRET)

Listar buckets

bucket_response = s3.list_buckets()
Introdução ao AWS Boto em Python

Listando buckets

Obter dicionário de buckets

buckets = bucket_response['Buckets']
print(buckets)
Introdução ao AWS Boto em Python

Listando buckets

Listagem de buckets

Introdução ao AWS Boto em Python

Excluindo buckets

Criar cliente boto3

import boto3
s3 = boto3.client('s3', region_name='us-east-1', 
                         aws_access_key_id=AWS_KEY_ID, 
                        aws_secret_access_key=AWS_SECRET)

Excluir bucket

response = s3.delete_bucket('gid-requests')
Introdução ao AWS Boto em Python

Tchau, bucket

Bucket removido

Introdução ao AWS Boto em Python

Tchau, bucket

Bucket removido

Introdução ao AWS Boto em Python

Outras operações

Documentação do Boto3 para o cliente S3

Introdução ao AWS Boto em Python

Resumo

s3.create_bucket(Bucket='buck')

s3.list_buckets()
s3.delete_bucket(Bucket='buck')

Objetos em bucket S3

Introdução ao AWS Boto em Python

Vamos praticar!

Introdução ao AWS Boto em Python

Preparing Video For Download...