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、--profile 或 boto3.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。
如何修正
列出你的環境實際看得到的內容:
aws configure list-profiles env | grep -i '^AWS_'修正或取消指標 —
unset AWS_PROFILE(或將它設為列出的 profile 之一),更正--profile/profile_name的拼字。檢查區段標頭:
# ~/.aws/config [profile myprofile] region = eu-west-1 # ~/.aws/credentials [myprofile] aws_access_key_id = ... aws_secret_access_key = ...若 profile 從未存在則建立它 —
aws configure --profile myprofile(或對 Identity Center profile 用aws configure sso)。在容器/CI 中,偏好使用環境憑證或角色,而非 profile 檔案 — 或將
AWS_CONFIG_FILE掛載/指向一個確實定義了該 profile 的檔案。
一旦 profile 解析成功,驗證它確實能連到你的表格 — DynoTable 桌面應用程式使用你的 AWS profile 來連線,並讓「哪個 profile 看得到哪些表格」變得可見,而 DynamoDB 定價計算器則協助規劃該帳戶工作負載的成本。
相關錯誤
- Unable to locate credentials — 完全找不到憑證(不涉及明確的 profile)。
- Could not load credentials from any providers — 同一鏈式失敗的 JS-SDK 版本。
- SSO session expired — profile 存在但其 SSO 登入已失效。
- 學習:DynamoDB Local & LocalStack setup
References
- Configuration and credential file settings in the AWS CLI — AWS CLI User Guide
- Configuring environment variables for the AWS CLI — AWS CLI User Guide (AWS_PROFILE, AWS_CONFIG_FILE, AWS_SHARED_CREDENTIALS_FILE)
- Configuring IAM Identity Center authentication with the AWS CLI — AWS CLI User Guide (aws configure sso)
最後驗證於 2026-07-13,對照上方連結的 AWS 官方文件。