Skip to main content

ENV Resolver (Python)

This is a small utility to resolve SSM Parameters and Secretsmanager Secrets and conditionally set them in the environment.

This is helpful for services like AWS Batch or AWS Lambda where there is not a way natively to pass secret values.

Install

pip install env-resolver

This package assumes that you already depend on boto3 and have it installed as a dependency of your project. If you are using this package in AWS Lambda, boto3 will already be available.

Quick Start

Parameter Store

from parameter_resolver import resolve

# assuming you've created two parameters:
# ssm/parameter/env-one = val-one
# ssm/parameter/env-two = val-two

parameters = {
    'ENV_ONE': 'ssm/parameter/env-one',
    'ENV_TWO': 'ssm/parameter/env-two'
}

print(resolve('ssm', parameters))

# Outputs:
# {
#     'ENV_ONE': 'val-one',
#     'ENV_TWO': 'val-two'
# }

Secrets Manager

from parameter_resolver import resolve

# assuming you've created the following secret:
# secret/secret-one =
# {
#     'ENV_ONE': 'val-one',
#     'ENV_TWO': 'val-two'
# }

secret = {
    'secret_id': 'secret/secret-one'
}

print(resolve('secretsmanager', secret))

# Outputs:
# {
#     'ENV_ONE': 'val-one',
#     'ENV_TWO': 'val-two'
# }

Usage

resolve(parameter_type, parameter_value, set_environment_variables=True)

These are the possible values for parameter_type:

  • ssm
  • secretsmanager

Options

The set_environment_variables options allows you to choose whether or not to set the new key-value pairs in the environment.

SSM

For a parameter store parameter, resolve expects the parameter_value to be a dictionary of KEY: PARAMETER_NAME.

Secretsmanager

For a secretsmanager secret, resolve expects the parameter_value to be a dictionary with the following possible values:

secret = {
    'secret_id': 'string',
    'version_id': 'string', # optional
    'json_value': 'boolean' # option, default=True
}

Contributing

PR's are welcome!

This project uses Poetry for dependency / environment management.

Install Dependencies

poetry install

Tests

poetry run pytest

Metadata

Release files for env-resolver 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for env-resolver 0.1.7
File Size Uploaded Provenance Actions
env_resolver-0.1.7.tar.gz 2.9 kB Without provenance Details for env_resolver-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for env-resolver 0.1.7
File Interpreter ABI Platform Actions
env_resolver-0.1.7-py3-none-any.whl Python 3 none any Details for env_resolver-0.1.7-py3-none-any.whl

Total release size: 5.9 kB

Release files / env_resolver-0.1.7.tar.gz

Download URL env_resolver-0.1.7.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ce3a150f8ba405af530678e28f5a712e1bef41b1672f61a23982acbf6c612cfa
BLAKE2b-256 checksum
How to use checksums
066d2ef8e25eb1aae48ec9e64c2d41efde5cd1f01d243fa62488440e0ac48920
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Linux/5.3.0-1022-azure

Release files / env_resolver-0.1.7-py3-none-any.whl

Download URL env_resolver-0.1.7-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95a45b488897f5fe3f193c3720d1cd040fb51c09db2cc319c551460433fd9c47
BLAKE2b-256 checksum
How to use checksums
d80f04990821e3c805dcad58e7e786a5b3d832aa07c402a016b9269f88a238b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Linux/5.3.0-1022-azure

Security for env-resolver 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page