深入了解 buckets

Python 中的 AWS Boto 入門

Maksim Pecherskiy

Data Engineer

S3 元件-Buckets

  • 桌面資料夾
  • 自訂權限原則
  • 網站儲存
  • 產生日誌

儲存桶

Python 中的 AWS Boto 入門

S3 元件-Objects

桶內的物件

Python 中的 AWS Boto 入門

Buckets 能做什麼?

  • 建立 Bucket
  • 列出 Buckets
  • 刪除 Bucket

儲存桶

Python 中的 AWS Boto 入門

建立 Bucket

建立 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)

建立 bucket!

bucket = s3.create_bucket(Bucket='gid-requests')
Python 中的 AWS Boto 入門

砰!

砰!建立桶

Python 中的 AWS Boto 入門

主控台中的 Bucket

主控台中的 Bucket

Python 中的 AWS Boto 入門

列出 Buckets

建立 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)

列出 Buckets

bucket_response = s3.list_buckets()
Python 中的 AWS Boto 入門

列出 Buckets

取得 Buckets 字典

buckets = bucket_response['Buckets']
print(buckets)
Python 中的 AWS Boto 入門

列出 Buckets

Bucket 清單

Python 中的 AWS Boto 入門

刪除 Buckets

建立 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)

刪除 Bucket

response = s3.delete_bucket('gid-requests')
Python 中的 AWS Boto 入門

再見了,Bucket

Bucket 已刪除

Python 中的 AWS Boto 入門

再見了,Bucket

Bucket 已刪除

Python 中的 AWS Boto 入門

其他操作

boto3 的 S3 用戶端文件

Python 中的 AWS Boto 入門

重點整理

s3.create_bucket(Bucket='buck')

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

S3 儲存桶中的物件

Python 中的 AWS Boto 入門

一起來練習吧!

Python 中的 AWS Boto 入門

Preparing Video For Download...