開始使用免費開始

你的第一個 boto3 用戶端

Sam 不想再受限於只能用她的電腦來做儲存與運算。她正在學習如何運用雲端的強大能力來建立資料管線,並自動產生報告。

在做這些之前,Sam 需要先建立她的第一個 boto3 用戶端,並查看 S3 中已存在的 bucket。

她的 AWS key 與 AWS secret key 分別已儲存在 AWS_KEY_IDAWS_SECRET

在本練習中,你將協助 Sam 建立你第一個連到 AWS 的 boto3 用戶端!

本練習屬於課程

Python 中的 AWS Boto 入門

檢視課程

練習說明

  • 建立一個可與 s3 互動的 boto3 用戶端。
  • region_name 指定為 'us-east-1'
  • 使用 AWS_KEY_IDAWS_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)
編輯並執行程式碼