Skip to main content

Omegaconf custom resolvers to retrieve configuration values from cloud services

Project description

Omegaconf Plugin: Cloud Secrets

This package is a plugin designed to enhance OmegaConf by providing additional custom resolvers to securely retrieve sensitive values that should not be hard-coded in your configuration files.

Currently, there are resolvers for:

  • AWS:
    • Secrets Manager
    • Parameter Store
  • Google Cloud Platform (GCP):
    • Secret Manager

Installation

  • AWS:
pip install omegaconf-cloud-resolvers[aws]
  • GCP:
pip install omegaconf-cloud-resolvers[gcp]

Quickstart

The following is an introductory example using a secret stored in AWS Secrets Manager.

First create a secret in the AWS Secrets Manager. You can use the CLI:

aws secretsmanager create-secret --name secret_jwt --secret-string 'thiscouldbe.a.jwt'
from omegaconf import OmegaConf
from omegaconf_cloud_resolvers import register_custom_resolvers
from omegaconf_cloud_resolvers.resolvers.aws import AWSSecretsManagerResolver

# Option A. Define an env var: `AWS_DEFAULT_PROFILE=<your-aws-profile>`
# If you do, there is no need to pass a Session to the PluginResolver

# Option B. Alternatively you can create a boto3 session and pass it to the `AWSSecretsManagerResolver`
# Check `.aws/config` to see what are your profiles.
#   from boto3 import Session
#   session = Session(profile_name="<your-aws-profile>")

# Define the custom resolver. The dict key is the name that you will use  in your config
resolvers = {
    "aws_secretsmanager": AWSSecretsManagerResolver(),
}
# Use CustomResolverInjector to declare the resolver. You cannot inject twice the same key.
register_custom_resolvers(**resolvers)

# The syntax is: <resolver-name>:<secret-name>
conf = OmegaConf.create({"secret": "${aws_secretsmanager:secret_jwt}"})
print("Your secret is:", conf["secret"])  # THAT IS AN ILLUSTRATIVE EXAMPLE, NEVER DO THIS IN PRODUCTION

Roadmap

  • Resolver for Azure Key Vault
  • Support for older version for the AWS Secrets Manager Resolver
  • Examples using AWS services - Lambda
  • Examples using Google Cloud Platform services - Functions

WARNING

This package is in a very early and experimental stage, use it under your own responsibility.

Troubleshooting

  • NoCredentialsError raised while resolving interpolation: Unable to locate credentials You might not have configured a default profile or provided with a session to a AWS Resolver.

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

omegaconf_cloud_resolvers-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

omegaconf_cloud_resolvers-0.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file omegaconf_cloud_resolvers-0.1.0.tar.gz.

File metadata

  • Download URL: omegaconf_cloud_resolvers-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.15 Linux/5.15.0-119-generic

File hashes

Hashes for omegaconf_cloud_resolvers-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57265f8ca9a7e26cb90fe05587d072aeae89bb11641ca3e50ea395159a7a53ff
MD5 9059bf784260f5e298eaf984090079bc
BLAKE2b-256 f9f3ac8e19e4823f3ccd04edf46d7b2b19de77dc030905cc19038a1dd7b7f262

See more details on using hashes here.

File details

Details for the file omegaconf_cloud_resolvers-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for omegaconf_cloud_resolvers-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd6625df2005da11fd11e1013a4a358293d29aea3ef46d9c8a00e3049384f1a9
MD5 20933b2fb38890863f77f0874b9a2d39
BLAKE2b-256 a98085f66cd12df7362d75d17db2b56773c4bb40276332f00a310e0150941d3a

See more details on using hashes here.

Supported by

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