你的第一個 boto3 用戶端
Sam 不想再受限於只能用她的電腦來做儲存與運算。她正在學習如何運用雲端的強大能力來建立資料管線,並自動產生報告。
在做這些之前,Sam 需要先建立她的第一個 boto3 用戶端,並查看 S3 中已存在的 bucket。
她的 AWS key 與 AWS secret key 分別已儲存在 AWS_KEY_ID 與 AWS_SECRET。
在本練習中,你將協助 Sam 建立你第一個連到 AWS 的 boto3 用戶端!
本練習屬於課程
Python 中的 AWS Boto 入門
練習說明
- 建立一個可與
s3互動的boto3用戶端。 - 將
region_name指定為'us-east-1'。 - 使用
AWS_KEY_ID與AWS_SECRET設定認證。 - 列印出這些 buckets。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Generate the boto3 client for interacting with S3
s3 = boto3.client('____', ____='us-east-1',
# Set up AWS credentials
aws_access_key_id=____,
aws_secret_access_key=____)
# List the buckets
buckets = s3.list_buckets()
# Print the buckets
print(buckets)