Skip to main content

Centralized Settings Loader for Python Apps

Project description

sai-akruti

Centralized, flexible settings loader for Python apps using Pydantic v2.x.

This library provides a reusable, extensible settings system with built-in support for:

  • Multiple .env files
  • AWS Systems Manager (SSM) Parameter Store
  • AWS Secrets Manager
  • Standard environment variables and secret files (handled via Pydantic automatically)

It’s designed for clean separation of settings logic and allows each app to define its own settings hierarchy, source priorities, and overrides.


✅ Features

  • Compatible with Pydantic v2.x (pydantic-settings).
  • Automatically loads settings on instantiation — no manual .load() needed.
  • Supports per-environment configuration (dev, prod, etc.).
  • Easy to extend for other sources (YAML, remote config, etc.).
  • Production-safe and future-proof.

✅ Installation

pip install sai-akruti

✅ AWS Credentials & IAM Permissions (Required)

This library can also use AWS Systems Manager (SSM) Parameter Store and AWS Secrets Manager for secure configuration. Required IAM Permissions:

Ensure your environment (developer machine, Lambda, EC2, ECS, etc.) has the following IAM permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ssm:GetParametersByPath",
        "secretsmanager:GetSecretValue"
      ],
      "Resource": "*"
    }
  ]
}

Best Practice: In production, restrict the "Resource" field to specific parameter/secret ARNs.

How Credentials Are Provided:

This library uses boto3's standard credential chain:

  • Environment Variables(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.)
  • ~/.aws/credentials or configured profiles (via aws configure).
  • IAM Role on EC2, Lambda, or ECS (via Instance Metadata Service).
  • AWS CLI SSO or other advanced credential providers.

Usage in Lambda Functions:

When used in an AWS Lambda function:

  • Assign an IAM Role to your Lambda function with the above permissions.
  • No manual credential configuration is needed—boto3 automatically uses the Lambda’s IAM Role.
  • Example IAM Policy for Lambda:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ssm:GetParametersByPath",
        "secretsmanager:GetSecretValue"
      ],
      "Resource": "arn:aws:ssm:REGION:ACCOUNT_ID:parameter/your-prefix/*"
    }
  ]
}

How to retrieve AWS Account ID:

To retrieve the AWS Account ID in your code:

import boto3
account_id = boto3.client("sts").get_caller_identity()["Account"]

How to release to PyPI manually: To release a new version to PyPI, follow these steps:

  1. Update the version in pyproject.toml.
  2. Build the package:
    python -m build
    
  3. Upload to PyPI:
     python publish
    

Special Note:

  • For SSM, if the parameter is defined as a String or SecretString and is a dict which has "keyName" as one of its keys, then it will be used as the key for the settings. Otherwise, the dictionary will be unpacked and each key will be used as a setting.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sai_akruti-0.3.9.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sai_akruti-0.3.9-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file sai_akruti-0.3.9.tar.gz.

File metadata

  • Download URL: sai_akruti-0.3.9.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for sai_akruti-0.3.9.tar.gz
Algorithm Hash digest
SHA256 06cb33338bf02b0b81f33d2f41e5daea14a05fb743a8d98f23431c5de9198e77
MD5 4521524bcb841443f2b4e267b4a5b69f
BLAKE2b-256 8d4bb3e1dcf4ec2e862348eca8242c99612fc8a8dac4ff95d170615d88963622

See more details on using hashes here.

File details

Details for the file sai_akruti-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: sai_akruti-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for sai_akruti-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 0d6c7fcc90091e742b6624f14371a65878676acf8b47126be9d1287cecdbf357
MD5 d7ca1862530b78e5e0b96035e094f5ee
BLAKE2b-256 ee846b02397d4a1819ebb5e32b77cfec135a858e1ff6e00612b1ea65129b4ce5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page