跳转到主要内容

Python Decouple的AWS扩展

项目描述

Latest PyPI version

Python Decouple AWS 帮助您组织并访问AWS Secrets Manager中的敏感信息。

它还使您能够

  1. 不重复boto3样板代码;

  2. 定义默认值;

  3. 使用os.environ作为后备;

支持Python 3.4+;

为什么

  • 单处保存所有秘密(AWS Secrets Manager);

  • 将敏感信息与代码和环境隔离开来;

  • 使用更简单的API访问AWS Secrets Manager(而不是boto3);

安装

pip install python-decouple-aws

使用示例1

#  settings.py
from decouple_aws import get_config

# The package provides a wrapper function that will
# fallback to environment variables and fail gracefully
# if AWS Secrets Manager is not accessible for whatever
# reason.
config = get_config('your-project/secret/name', 'ap-southeast-2')

# Use decouple config like normal
MY_EMAIL_USER = config('MY_EMAIL_USER', 'default-user')
MY_EMAIL_PASS = config('MY_EMAIL_PASS')

使用示例2

# settings.py
from decouple import Config
from decouple_aws import RepositoryAwsSecretManager

# if you would like it to fail if secrets
# manager is inaccessible, you can build it manually.
# initialise the config with the AWS repository
# Pass the repo your secret name and the region
repo = RepositoryAwsSecretManager('your-project/secret/name', 'ap-southeast-2')
config = Config(repo)

# Use decouple config like normal
MY_SUPER_SECRET_SETTING = config('MY_SUPER_SECRET_SETTING')

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

python-decouple-aws-0.3.2.tar.gz (3.5 kB 查看哈希)

上传时间:

构建分布

python_decouple_aws-0.3.2-py3-none-any.whl (5.4 kB 查看哈希值)

上传时间 Python 3

由以下支持