The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(bedrock): allow bedrock-mantle:CreateInference in the web identity session policy
mateo-berri201730efe573
diff --git a/litellm/llms/bedrock/base_aws_llm.py b/litellm/llms/bedrock/base_aws_llm.pyindex f449851b76f..df811f8d262 100644--- a/litellm/llms/bedrock/base_aws_llm.py+++ b/litellm/llms/bedrock/base_aws_llm.py@@ -877,6 +877,15 @@ class BaseAWSLLM:"Resource": "*","Condition": {"Bool": {"aws:SecureTransport": "true"}},},+ {+ "Sid": "BedrockMantleLiteLLM",+ "Effect": "Allow",+ "Action": [+ "bedrock-mantle:CreateInference",+ ],+ "Resource": "*",+ "Condition": {"Bool": {"aws:SecureTransport": "true"}},+ },],}assume_role_params = {diff --git a/tests/test_litellm/llms/bedrock/test_web_identity_session_policy.py b/tests/test_litellm/llms/bedrock/test_web_identity_session_policy.pyindex 7e9c8a273ae..0cbdc518cc2 100644--- a/tests/test_litellm/llms/bedrock/test_web_identity_session_policy.py+++ b/tests/test_litellm/llms/bedrock/test_web_identity_session_policy.py@@ -158,6 +158,54 @@ class TestClaudePlatformActionsCovered:)+class TestBedrockMantleActionsCovered:+ """LIT-3859: bedrock_mantle inference authorizes against the+ ``bedrock-mantle`` action namespace, so the session-policy ceiling+ must include it or every Mantle request via OIDC/WIF auth denies+ with "no session policy allows the bedrock-mantle:CreateInference+ action" even when the role's identity policy grants it."""++ def test_bedrock_mantle_create_inference_present(self):+ policy = _captured_policy()+ all_actions: set = set()+ for stmt in policy["Statement"]:+ stmt_actions = stmt.get("Action")+ if isinstance(stmt_actions, str):+ all_actions.add(stmt_actions)+ elif isinstance(stmt_actions, list):+ all_actions.update(stmt_actions)+ assert "bedrock-mantle:CreateInference" in all_actions, (+ "bedrock-mantle:CreateInference missing from session policy — "+ "bedrock_mantle/* requests will 403 on OIDC/WIF auth"+ )++ def test_bedrock_mantle_statement_allows(self):+ policy = _captured_policy()+ stmt = _statement_by_sid(policy, "BedrockMantleLiteLLM")+ assert stmt["Effect"] == "Allow"+ assert stmt["Resource"] == "*"++ def test_no_bedrock_mantle_wildcard(self):+ policy = _captured_policy()+ stmt = _statement_by_sid(policy, "BedrockMantleLiteLLM")+ actions = stmt["Action"]+ if isinstance(actions, str):+ actions = [actions]+ assert "bedrock-mantle:*" not in actions, (+ "session policy must not grant bedrock-mantle:* — "+ "the ceiling should match the documented action set"+ )++ def test_bedrock_mantle_statement_carries_secure_transport_condition(self):+ policy = _captured_policy()+ stmt = _statement_by_sid(policy, "BedrockMantleLiteLLM")+ cond = stmt.get("Condition") or {}+ assert cond.get("Bool", {}).get("aws:SecureTransport") == "true", (+ "BedrockMantleLiteLLM must require aws:SecureTransport=true "+ "to keep parity with the bedrock statement"+ )++def _make_jwt(payload: dict) -> str:def _segment(data: dict) -> str:return base64.urlsafe_b64encode(json.dumps(data).encode()).rstrip(b"=").decode()