{"id":13850058,"url":"https://github.com/christippett/ssm-parameter-store","last_synced_at":"2025-04-14T21:51:52.525Z","repository":{"id":55928016,"uuid":"128541569","full_name":"christippett/ssm-parameter-store","owner":"christippett","description":"A simple Python library for getting values from AWS Systems Manager Parameter Store","archived":false,"fork":false,"pushed_at":"2023-05-04T06:14:29.000Z","size":42,"stargazers_count":32,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T17:56:35.876Z","etag":null,"topics":["aws","django","hacktoberfest","parameter-store","secret-management"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christippett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-07T15:26:19.000Z","updated_at":"2025-03-27T21:50:12.000Z","dependencies_parsed_at":"2024-01-18T10:11:57.531Z","dependency_job_id":"b610f24b-c86c-4091-963c-58fcd5405a40","html_url":"https://github.com/christippett/ssm-parameter-store","commit_stats":{"total_commits":76,"total_committers":4,"mean_commits":19.0,"dds":0.07894736842105265,"last_synced_commit":"e001466d288863a7e9a9c0240274425ab9d6fa84"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fssm-parameter-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fssm-parameter-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fssm-parameter-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fssm-parameter-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christippett","download_url":"https://codeload.github.com/christippett/ssm-parameter-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968741,"owners_count":21191158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","django","hacktoberfest","parameter-store","secret-management"],"created_at":"2024-08-04T20:00:57.489Z","updated_at":"2025-04-14T21:51:52.507Z","avatar_url":"https://github.com/christippett.png","language":"Python","funding_links":[],"categories":["AWS Misc"],"sub_categories":[],"readme":"SSM Parameter Store\n=============================================================\n\n[![PyPI version](https://img.shields.io/pypi/v/ssm-parameter-store.svg)](https://pypi.python.org/pypi/ssm-parameter-store)\n[![Build status](https://img.shields.io/travis/christippett/ssm-parameter-store.svg)](https://travis-ci.org/christippett/ssm-parameter-store)\n[![Coverage](https://img.shields.io/coveralls/github/christippett/ssm-parameter-store.svg)](https://coveralls.io/github/christippett/ssm-parameter-store?branch=master)\n[![Python versions](https://img.shields.io/pypi/pyversions/ssm-parameter-store.svg)](https://pypi.python.org/pypi/ssm-parameter-store)\n[![Github license](https://img.shields.io/github/license/christippett/ssm-parameter-store.svg)](https://github.com/christippett/ssm-parameter-store)\n\nDescription\n===========\n\nThis is a simple Python wrapper for getting values from AWS Systems Manager\nParameter Store.\n\nThe module supports getting a single parameter, multiple parameters or all parameters matching a particular path.\n\nAll parameters are returned as a Python `dict`.\n\nInstallation\n============\n\nInstall with `pip`:\n\n``` bash\npip install ssm-parameter-store\n```\n\nUsage\n=====\n\nImport the module and create a new instance of `EC2ParameterStore`.\n\n```python\nfrom ssm_parameter_store import EC2ParameterStore\n\nstore = EC2ParameterStore()\n```\n\nAWS Credentials\n---------------\n\n`ssm-parameter-store` uses `boto3` under the hood and therefore inherits\nthe same mechanism for looking up AWS credentials. See [configuring\ncredentials](https://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials)\nin the Boto 3 documentation for more information.\n\n`EC2ParameterStore` accepts all `boto3` client parameters as keyword arguments.\n\nFor example:\n\n``` python\nfrom ssm_parameter_store import EC2ParameterStore\n\nstore = EC2ParameterStore(\n    aws_access_key_id=ACCESS_KEY,\n    aws_secret_access_key=SECRET_KEY,\n    aws_session_token=SESSION_TOKEN,  # optional\n    region_name='us-west-2'\n)\n```\n\nExamples\n========\n\nGiven the following parameters:\n\n``` bash\n# set default AWS region\nAWS_DEFAULT_REGION=us-west-2\n\n# add parameters\naws ssm put-parameter --name \"param1\" --value \"value1\" --type SecureString\naws ssm put-parameter --name \"param2\" --value \"value2\" --type SecureString\n\n# add parameters organised by hierarchy\naws ssm put-parameter --name \"/dev/app/secret\" --value \"dev_secret\" --type SecureString\naws ssm put-parameter --name \"/dev/db/postgres_username\" --value \"dev_username\" --type SecureString\naws ssm put-parameter --name \"/dev/db/postgres_password\" --value \"dev_password\" --type SecureString\naws ssm put-parameter --name \"/prod/app/secret\" --value \"prod_secret\" --type SecureString\naws ssm put-parameter --name \"/prod/db/postgres_username\" --value \"prod_username\" --type SecureString\naws ssm put-parameter --name \"/prod/db/postgres_password\" --value \"prod_password\" --type SecureString\n```\n\n\nGet a single parameter\n----------------------\n\n``` python\nparameter = store.get_parameter('param1', decrypt=True)\n\nassert parameter == {\n   'param1': 'value1'\n}\n```\n\nGet multiple parameters\n-----------------------\n\n``` python\nparameters = store.get_parameters(['param1', 'param2'])\n\nassert parameters == {\n   'param1': 'value1',\n   'param2': 'value2',\n}\n```\n\nGet parameters by path\n----------------------\n\n``` python\nparameters = store.get_parameters_by_path('/dev/', recursive=True)\n\nassert parameters == {\n    'secret': 'dev_secret',\n    'postgres_username': 'dev_username',\n    'postgres_password': 'dev_password',\n}\n```\n\nBy default `get_parameters_by_path` strips the path from each parameter name. To return a parameter's full name, set `strip_path` to `False`.\n\n``` python\nparameters = store.get_parameters_by_path('/dev/', strip_path=False, recursive=True)\n\nassert parameters == {\n    '/dev/app/secret': 'dev_secret',\n    '/dev/db/postgres_username': 'dev_username',\n    '/dev/db/postgres_password': 'dev_password'\n}\n```\n\nGet parameters with original hierarchy\n--------------------------------------\nYou can also get parameters by path, but in a nested structure that models the path hierarchy.\n\n``` python\nparameters = store.get_parameters_with_hierarchy('/dev/')\n\nassert parameters == {\n    'app': {\n        'secret': 'dev_secret',\n    },\n    'db': {\n        'postgres_username': 'dev_username',\n        'postgres_password': 'dev_password',\n    },\n}\n```\n\nBy default `get_parameters_with_hierarchy` strips the leading path component. To return the selected parameters\nwith the full hierarchy, set `strip_path` to `False`.\n\n``` python\nparameters = store.get_parameters_with_hierarchy('/dev/', strip_path=False)\n\nassert parameters == {\n    'dev': {\n        'app': {\n            'secret': 'dev_secret',\n        },\n        'db': {\n            'postgres_username': 'dev_username',\n            'postgres_password': 'dev_password',\n        },\n    },\n}\n```\n\n\nPopulating Environment Variables\n================================\n\nThe module includes a static method on `EC2ParameterStore` to help populate environment variables. This can be helpful when integrating with a library like [`django-environ`](https://github.com/joke2k/django-environ).\n\nExample\n-------\nGiven the following parameters:\n\n```bash\naws ssm put-parameter --name \"/prod/django/SECRET_KEY\" --value \"-$y_^@69bm69+z!fawbdf=h_10+zjzfwr8_c=$$\u0026j@-%p$%ct^\" --type SecureString\naws ssm put-parameter --name \"/prod/django/DATABASE_URL\" --value \"psql://user:pass@db-prod.xyz123.us-west-2.rds.amazonaws.com:5432/db\" --type SecureString\naws ssm put-parameter --name \"/prod/django/REDIS_URL\" --value \"redis://redis-prod.edc1ba.0001.usw2.cache.amazonaws.com:6379\" --type SecureString\n```\n\n```python\nimport environ\nfrom ssm_parameter_store import EC2ParameterStore\n\nenv = environ.Env(\n    DEBUG=(bool, False)\n)\n\n# Get parameters and populate os.environ (region not required if AWS_DEFAULT_REGION environment variable set)\nparameter_store = EC2ParameterStore(region_name='us-west-2')\ndjango_parameters = parameter_store.get_parameters_by_path('/prod/django/', strip_path=True)\nEC2ParameterStore.set_env(django_parameters)\n\n# False if not in os.environ\nDEBUG = env('DEBUG')\n\n# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ\nSECRET_KEY = env('SECRET_KEY')\n\nDATABASES = {\n    # read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found\n    'default': env.db(),\n}\n\nCACHES = {\n    'default': env.cache('REDIS_URL'),\n}\n```\n\nRelated Projects\n================\n\n- **[param-store](https://github.com/LabD/python-param-store)** – \nPython module to store secrets in secret stores\n- **[ssm-cache](https://github.com/alexcasalboni/ssm-cache-python)** –\nAWS System Manager Parameter Store caching client for Python\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristippett%2Fssm-parameter-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristippett%2Fssm-parameter-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristippett%2Fssm-parameter-store/lists"}