放置秘密储藏室的腐殖层
humilis-secrets-vault的Python项目详细描述
一个 humilis 实现secrets-vault层的插件该层包括 一个加密的dynamodb表,在 同样的腐殖质环境。秘密的加密和解密 由AWSKMS service处理
安装
来自PyPI:
pip install humilis-secrets-vault
安装开发版本:
pip install git+https://github.com/InnovativeTravel/humilis-secrets-vault
我怎么用这个?
只需将此层添加到 humilis 环境并使用层参数associated_processors来 指定包含需要访问的lambda函数的层 在地下室的秘密例如,下面的环境部署 处理动觉流中事件的Lambda函数羔羊 处理器被授予访问机密库的权限,机密库也是 相同的环境:
--- myenvironment: description: An environment with a Lambda processor to filter events in a Kinesis stream. layers: - layer: streams layer_type: streams streams: - name: InputStream shard_count: 1 - layer: event-processor layer_type: kinesis-processor dependencies: ["streams"] input: {layer: streams, stream: InputStream} - layer: secrets-vault layer_type: secrets-vault # We specify that the Lambda function in the event-processor layer # should have access to the secrets in the vault. associated_processors: ["event-processor"]
secrets-vault层希望包含 lambda处理器使用 了解lambda函数,该函数应该可以访问 拱顶。类型层 kinesis-processor 在上面的例子中,实现了这个期望,这样他们就可以工作了 开箱即用。
检索机密
从Lambda函数检索机密的最简单方法是 包含包 lambdautils作为 依赖性。
然后你可以很容易地从你的lambda中的保险库中检索秘密 代码如下:
import lambdautils.utils as utils # Assuming that you are deploying this Lambda with humilis the line below # will indicate humilis to preprocess this function with Jinja2 before # producing the Lambda deployment package. # preprocessor:jinja2 # During deployment, humilis will replace here the name of the humilis # environment and deployment stage. ENVIRONMENT = "{{_env.name}}" STAGE = "{{_env.stage}}" plaintext = utils.get_secret( "my_secret_key", environment=ENVIRONMENT, stage=STAGE)
储存秘密
你可以用 humilis 要从命令行将机密存储在保险库中,请执行以下操作:
humilis set-secret --stage [STAGE] [ENVIRONMENT_FILE] [SECRET_KEY] [SECRET_VALUE]
测试
您可以使用:
make create
然后,您可以运行集成测试套件(TBD):
make testi
完成后不要忘记删除测试部署:
make delete
更多信息
见 humilis 文档。
联系人
如果您有问题、错误报告、建议等,请创建 关于GitHub project page的问题