{"record":{"id":"0ae2ccdcd69ae334","repo":"BerriAI/litellm","slug":"bedrockexception-permissiondeniederror-error-st","errorCode":null,"errorMessage":"BedrockException PermissionDeniedError - {error_str}","messagePattern":"BedrockException PermissionDeniedError - (.+?)","errorType":"exception","errorClass":"PermissionDeniedError","httpStatus":403,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":869,"sourceCode":"    elif \"A conversation must start with a user message.\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\\n. Pass in default user message via `completion(..,user_continue_message=)` or enable `litellm.modify_params=True`.\\nFor Proxy: do via `litellm_settings::modify_params: True` or user_continue_message under `litellm_params`\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif (\n        \"Unable to locate credentials\" in error_str\n        or \"The security token included in the request is invalid\" in error_str\n    ):\n        raise AuthenticationError(\n            message=f\"BedrockException Invalid Authentication - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"AccessDeniedException\" in error_str:\n        raise PermissionDeniedError(\n            message=f\"BedrockException PermissionDeniedError - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"throttlingException\" in error_str or \"ThrottlingException\" in error_str:\n        raise RateLimitError(\n            message=f\"BedrockException: Rate Limit Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Connect timeout on endpoint URL\" in error_str or \"timed out\" in error_str:\n        raise Timeout(\n            message=f\"BedrockException: Timeout Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L851-L887","documentation":"LiteLLM throws PermissionDeniedError when Bedrock returns AccessDeniedException: request signing succeeded (credentials are valid) but the principal is not authorized to invoke that model. Distinct from the AuthenticationError branch above - here it is an IAM/model-access authorization failure, HTTP 403-shaped.","triggerScenarios":"IAM principal lacks bedrock:InvokeModel (or bedrock:InvokeModelWithResponseStream for streaming) on the model / inference-profile ARN; foundation model access never granted in the Bedrock console for that region; cross-account inference profile use without a resource policy.","commonSituations":"Fresh AWS accounts where model access was never requested; IAM users whose policies predate Bedrock and lack the bedrock:InvokeModel action; regional inference profiles (us./eu. prefixes) not covered by the policy; granting access in one region but calling another.","solutions":["Bedrock console -> Model access: request/enable access for the exact model in the exact region being called","Attach an IAM policy allowing bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on the model ARN (arn:aws:bedrock:<region>::foundation-model/<model-id>) and the inference-profile ARN","For cross-region inference profiles, also grant bedrock:InvokeModel on the application-inference-profile ARN","Confirm aws_region_name matches the region where access was granted, and the model string's profile prefix (us./eu./apac.) matches"],"exampleFix":"# before: policy has only s3 permissions\nlitellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs)  # AccessDeniedException\n\n# after: attach policy\n# {\"Version\": \"2012-10-17\", \"Statement\": [{\"Effect\": \"Allow\",\n#   \"Action\": [\"bedrock:InvokeModel\", \"bedrock:InvokeModelWithResponseStream\"],\n#   \"Resource\": [\"arn:aws:bedrock:*:::foundation-model/*\", \"arn:aws:bedrock:*:<account>:inference-profile/*\"]}]}\nlitellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import litellm\n\ndef is_permission_denied(e: BaseException) -> bool:\n    return isinstance(e, litellm.PermissionDeniedError)","tryCatchPattern":"try:\n    resp = litellm.completion(model='bedrock/...', messages=msgs)\nexcept litellm.PermissionDeniedError as e:\n    raise RuntimeError(\n        'Bedrock access denied: enable model access in the Bedrock console for region '\n        f'{aws_region} and grant bedrock:InvokeModel on the model ARN'\n    ) from e","preventionTips":["Enable Bedrock model access per region at account setup time, not at first call","Grant bedrock:InvokeModel(+WithResponseStream) on foundation-model and inference-profile ARNs in the IAM policy","Keep aws_region_name and the model's region/inference-profile prefix in sync","Add a startup canary call to each bedrock model to surface authorization gaps before traffic"],"tags":["bedrock","iam","access-denied","model-access"],"backgroundTag":"access-denied-iam","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}