Skip to content

feat: support Amazon Bedrock through the AWS SDK credential chain - #123

Open
kabigon-1015 wants to merge 1 commit into
openai:mainfrom
kabigon-1015:feat/amazon-bedrock-provider
Open

feat: support Amazon Bedrock through the AWS SDK credential chain#123
kabigon-1015 wants to merge 1 commit into
openai:mainfrom
kabigon-1015:feat/amazon-bedrock-provider

Conversation

@kabigon-1015

@kabigon-1015 kabigon-1015 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Adds a provider input (openai (default) | amazon-bedrock) so Codex can run against OpenAI models on Amazon Bedrock, authenticating through the AWS SDK credential chain — e.g. short-lived OIDC credentials from aws-actions/configure-aws-credentials — with no long-lived keys stored in the repository.

Addresses #107.

permissions:
  id-token: write
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/codex-bedrock-role
      aws-region: us-east-1
  - uses: openai/codex-action@v1
    with:
      provider: amazon-bedrock
      model: openai.gpt-5.6-sol
      permission-profile: ":read-only"
      prompt: "Review the public change."

Design notes

  • No credential inputs, no credential forwarding. The Codex CLI already resolves AWS credentials and region through the SDK credential chain (env, OIDC web identity, shared config, instance role, AWS_BEARER_TOKEN_BEDROCK), and runCodexExec spawns codex with the inherited environment. The action only selects the provider (--config model_provider="amazon-bedrock") and validates inputs. This keeps the action-side surface minimal and supports every auth method the CLI supports, including enterprise setups where long-lived keys are prohibited.
  • Read server info is skipped for Bedrock. Its current condition (openai-api-key != '' || prompt != '') makes any keyless run with a prompt poll for a server-info file that no proxy ever writes, then fail. This gating fix is required for any proxy-less provider to work.
  • Hardening stays on. drop-sudo, its verification, and the user-namespace setup for the sandbox now also run for the Bedrock path.
  • Fail fast on misconfiguration: openai-api-key combined with provider: amazon-bedrock is rejected (the proxy and the credential chain are mutually exclusive by design), as is a missing AWS_REGION/AWS_DEFAULT_REGION.
  • codex-args still wins. The provider config is pushed before extraArgs, so callers can layer provider settings such as model_providers.amazon-bedrock.aws.profile.

Relationship to #111

#111 pioneered the provider input (thank you @Suto-Michimasa!). This PR takes a different approach to authentication — delegating entirely to the AWS SDK credential chain instead of validating/forwarding specific credential env vars — and additionally fixes the Read server info gating that otherwise fails a keyless run. Happy to converge the two PRs in whichever direction the maintainers prefer.

Known limitations (documented)

  • safety-strategy: unprivileged-user is not supported with Bedrock: sudo resets the environment, so chain-resolved credentials do not reach the Codex process. The README directs users to drop-sudo/read-only.
  • Because there is no proxy, credentials are visible to the Codex process; docs/security.md now recommends short-lived OIDC credentials scoped to Bedrock inference only.

Verification

  • pnpm run check / pnpm run build / pnpm test (4 new unit tests covering the provider flag, default behavior, codex-args ordering, and invalid-provider rejection)

  • End-to-end run on GitHub Actions (ubuntu-latest), pinned to this branch's head SHA: OIDC → aws-actions/configure-aws-credentials (no long-lived keys, no AWS_BEARER_TOKEN_BEDROCK) → provider: amazon-bedrock / model: openai.gpt-5.6-luna / sandbox: read-only. The job succeeded end to end; sanitized log excerpt:

    # proxy install / "Read server info" steps: skipped (no openai-api-key)
    Confirmed sudo privilege is disabled.
    Running: CODEX_HOME=/home/runner/.codex codex "exec" "--skip-git-repo-check" \
      "--cd" "..." "--output-last-message" "..." \
      "--model" "openai.gpt-5.6-luna" \
      "--config" "model_provider=\"amazon-bedrock\"" "--sandbox" "read-only"
    codex> pong
    final-message: pong   # propagated through the action output
    

    This confirms the credential chain path works with OIDC-issued temporary credentials only, the proxy steps are cleanly skipped, and the drop-sudo hardening still runs for the Bedrock path.

🤖 Generated with Claude Code

Add a provider input ('openai' | 'amazon-bedrock') to run Codex against
OpenAI models on Amazon Bedrock without the Responses API proxy.

- Authentication is delegated entirely to the AWS SDK credential chain
  (e.g. short-lived OIDC credentials from
  aws-actions/configure-aws-credentials), so no key input or credential
  forwarding is added.
- Skip proxy installation and the 'Read server info' step when the
  provider is 'amazon-bedrock'; without this, a keyless run with a
  prompt fails after polling for a server info file that no proxy ever
  writes.
- Keep the drop-sudo hardening and user-namespace setup active for the
  Bedrock path.
- Fail fast on conflicting inputs (openai-api-key with amazon-bedrock)
  and on a missing AWS region.
- Document the OIDC setup in the README and the credential-exposure
  trade-off in docs/security.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@kabigon-1015

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 28, 2026
@kabigon-1015
kabigon-1015 marked this pull request as ready for review July 28, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant