Use Python to get a secret from AWS Secrets Manager and cache it.

IntermediateHands-onPython for DevOps
Answer
import functools
import json
import boto3

sm = boto3.client("secretsmanager")

@functools.lru_cache(maxsize=32)
def get_secret(name: str) -> dict:
    value = sm.get_secret_value(SecretId=name)["SecretString"]
    return json.loads(value)

db = get_secret("prod/app/db")
print(db["username"])

Key trick → Caching avoids per-request API calls (cost and throttling). In production add a TTL (or use AWS's caching client) so rotated secrets are picked up.

All Real-World Interview questions Roadmap: Interview readiness

More on Python for DevOps