anomalyco / anomalyco/opencode
provider: Bedrock hidden when AWS credentials exist but no AWS_* env var is exported
Open
@rekram1-node is already working on this.
Since Sep 8, 2026.
2.0
enhancement
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Problem
After #47436 and #47548, Bedrock is listed when any of these is present:
AWS_BEARER_TOKEN_BEDROCKor a/connectAPI key (bearer)AWS_PROFILE,AWS_ACCESS_KEY_ID,AWS_WEB_IDENTITY_TOKEN_FILE,AWS_CONTAINER_CREDENTIALS_*(SigV4 via the AWS default chain)options.profileinopencode.json
Availability is a presence check on those signals. Two common setups have working AWS credentials but export none of them, so Bedrock stays hidden even though a request would succeed:
- Bare
[default]profile —aws login,aws sso login, oraws configurewith noAWS_PROFILEexported. - EC2 instance role (IMDS) — credentials come from the instance metadata endpoint; there is no env var to detect. (#35798)
Related: #40663, #34997, #43681.
Workaround (works today)
Listing the provider in config force-enables it; the default chain then resolves credentials per request:
// opencode.json
{ "providers": { "amazon-bedrock": {} } }
// or with a named profile
{ "providers": { "amazon-bedrock": { "options": { "profile": "work" } } } }
Proposed: /connect amazon-bedrock → "AWS credentials"
Add a second connect method alongside the existing API key:
/connect amazon-bedrock
├─ API key (exists)
└─ AWS credentials (new)
Profile: [________] optional; blank = default chain
→ run the AWS default chain once to verify
ok → store credential, Bedrock listed
fail → surface the SDK error (e.g. "session expired, run aws login")
Shape:
- Stored credential holds only
{ profile? }— no AWS secrets, no expiry, no refresh.packages/aialready builds a fresh chain per request, so rotation and re-login are picked up without restart. - Needs a credential shape for "credentials live outside opencode". Options: a new
externalcredential type (reuse theoauth/autoconnect UI as the Azure CLI method does, no client changes), or makekeyoptional on the key method and add a profile field (one screen, touches the key form in app/cli/tui). model-resolverinjects nothing for such a credential;profileflows into settings throughmetadataas it does today.
Not proposed
- Probing the chain at startup or in
available()to auto-detect these cases. It does file/network I/O on a hot path and swallows errors; the explicit connect step is preferable. - Auto-running
aws sso loginon expiry (#1934) — separate feature.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.