BerriAI/litellm · error · ValueError

Missing required environment variable - AWS_REGION_NAME

Error message

Missing required environment variable - AWS_REGION_NAME

What it means

Module-level environment check for the AWS secret/KMS integration: it fires when AWS_REGION_NAME is absent from os.environ, meaning the AWS Secrets Manager/KMS client cannot be constructed. Set the variable before instantiating the manager or calling load_aws_kms.

Source

Thrown at litellm/secret_managers/aws_secret_manager.py:23

Requires:
* `os.environ["AWS_REGION_NAME"],
* `pip install boto3>=1.28.57`
"""

import ast
import base64
import os
import re
from typing import Any, Final

import litellm
from litellm.proxy._types import KeyManagementSystem


def validate_environment():
    if "AWS_REGION_NAME" not in os.environ:
        raise ValueError("Missing required environment variable - AWS_REGION_NAME")


def load_aws_kms(use_aws_kms: bool | None):
    if use_aws_kms is None or use_aws_kms is False:
        return
    try:
        import boto3

        validate_environment()

        # Create a Secrets Manager client
        kms_client: Final = boto3.client("kms", region_name=os.getenv("AWS_REGION_NAME"))

        litellm.secret_manager_client = kms_client
        litellm._key_management_system = KeyManagementSystem.AWS_KMS

    except Exception as e:
        raise e

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set AWS_REGION_NAME in the environment (e.g. export AWS_REGION_NAME=us-east-1) before initializing the AWS secret manager.
  2. Alternatively configure the region via AWS config files or pass it through litellm's key_management_settings.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/secret_managers/aws_secret_manager.py:23 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e0c4cd3058bc47e5. Report an issue: GitHub.