Solution skill
Error after running `list_foundation_models`
Complete solution
Shows how to fix error after running `list_foundation_models`. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Set AWSDEFAULTREGION to a region where Bedrock is enabled and AWS_PROFILE to your configured profile. Verify with aws sts get-caller-identity (run aws configure from a real terminal, not a notebook cell, since notebook cells are not interactive).
Steps
- NoCredentialsError from listfoundationmodels does not mean the client failed to build; boto3 creates the client fine and only fetches credentials lazily at request time. Verify with
aws sts get-caller-identity(runaws configurefrom a real terminal, not a notebook cell, since notebook cells are not interactive). If you get AccessDenied instead, your account needs Bedrock model access: AWS Console > Bedrock > Model access, enable the models. Set AWSDEFAULTREGION to a region where Bedrock is enabled and AWSPROFILE to your configured profile. BEDROCKASSUME_ROLE is only needed if you must assume a different role than your default identity for Bedrock calls.
When to use
You are seeing this: NoCredentialsError from listfoundationmodels does not mean the client failed to build; boto3 creates the client fine and only fetches credentials lazily at request time. Use this skill when you run into "Error after running list_foundation_models".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/aws-samples/amazon-bedrock-workshop/blob/main/00Intro/bedrockboto3_setup.ipynb
Evidence
In the GitHub issue gh:aws-samples/amazon-bedrock-workshop#20 (https://github.com/aws-samples/amazon-bedrock-workshop/issues/20), the problem reported was: Issue aws-samples/amazon-bedrock-workshop#20 (closed, 25 comments): I receive the following error after running this line boto3_bedrock.list_foundation_models() in https://github.com/aws-samples/amazon-bedrock-workshop/blob/main/00Intro/bedrockboto3setup.ipynb ``` NoCredentialsError Traceback (most recent call last) Cell In[11], line 1 ----> 1 boto3bedrock.listfoundationmodels() File [~/Downloads/repos/bedrock/.venv/lib/python3.11/site-packages/botocore/client.py:530]([a local notebook file path]]/... The verified resolution was: NoCredentialsError from listfoundationmodels does not mean the client failed to build; boto3 creates the client fine and only fetches credentials lazily at request time. Verify with aws sts get-caller-identity (run aws configure from a real terminal, not a notebook cell, since notebook cells are not interactive). If you get AccessDenied instead, your account needs Bedrock model access: AWS Console > Bedrock > Model access, enable the models. Set AWSDEFAULTREGION to a region where Bedrock is enabled and AWSPROFILE to your configured profile. BEDROCKASSUME_ROLE is only needed if you must assume a different role than your default identity for Bedrock calls.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_7nnPcQRe47scgm2m6VkqoA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error after running `list_foundation_models` <span>— Vectle</span></a>