The config profile could not be found

TL;DR — 你所使用的 profile 名稱不存在於你的行程正在讀取的 AWS 設定檔中。三個常見疑犯:過時的 AWS_PROFILE 環境變數、--profile/profile_name 中的拼字錯誤,或 profile 定義在錯誤的區段標頭下 — ~/.aws/config 檔案需要 [profile myprofile],而 ~/.aws/credentials 使用單純的 [myprofile]。執行 aws configure list-profiles 並比對。

這是什麼意思

botocore.exceptions.ProfileNotFound: The config profile (myprofile) could not be found

在任何 DynamoDB 呼叫可被簽署之前,SDK 會解析一個憑證 profile。如果一個 profile 被_明確請求_ — 透過 AWS_PROFILE--profileboto3.Session(profile_name=...) — 而正被讀取的設定/憑證檔案中沒有該名稱的區段,解析就會以此錯誤停止。什麼都沒送到 AWS;這完全是本機設定查找失敗。

為什麼會發生

  • AWS_PROFILE 指向一個不存在的 profile — 很久以前設定在 shell rc 檔、容器映像或 CI 設定中,之後 profile 被改名或移除。
  • 拼字錯誤或大小寫不符 — profile 名稱是精確比對的。
  • 區段標頭語法錯誤 — 在 ~/.aws/config 中,具名 profile 必須宣告為 [profile myprofile];在那裡寫 [myprofile] 會讓 CLI/SDK 找不到它(單純形式屬於 ~/.aws/credentials)。
  • 檔案不在行程查找的位置AWS_CONFIG_FILE/AWS_SHARED_CREDENTIALS_FILE 覆寫了路徑、在 sudo/服務使用者下有不同的家目錄,或容器沒有掛載 ~/.aws

如何修正

  1. 列出你的環境實際看得到的內容:

    aws configure list-profiles
    env | grep -i '^AWS_'
  2. 修正或取消指標unset AWS_PROFILE(或將它設為列出的 profile 之一),更正 --profile/profile_name 的拼字。

  3. 檢查區段標頭:

    # ~/.aws/config
    [profile myprofile]
    region = eu-west-1
    
    # ~/.aws/credentials
    [myprofile]
    aws_access_key_id = ...
    aws_secret_access_key = ...
  4. 若 profile 從未存在則建立它aws configure --profile myprofile(或對 Identity Center profile 用 aws configure sso)。

  5. 在容器/CI 中,偏好使用環境憑證或角色,而非 profile 檔案 — 或將 AWS_CONFIG_FILE 掛載/指向一個確實定義了該 profile 的檔案。

一旦 profile 解析成功,驗證它確實能連到你的表格 — DynoTable 桌面應用程式使用你的 AWS profile 來連線,並讓「哪個 profile 看得到哪些表格」變得可見,而 DynamoDB 定價計算器則協助規劃該帳戶工作負載的成本。

相關錯誤

References

最後驗證於 2026-07-13,對照上方連結的 AWS 官方文件。

不必透過主控台就能操作 DynamoDB

DynoTable 是一款快速的 DynamoDB 桌面用戶端 — 瀏覽表格、執行 SQL 風格的查詢,並在本機編輯項目。