|
1 | | -# python-aws-ssm |
| 1 | +[](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/PaddleHQ/python-aws-ssm) |
| 2 | +[](https://codecov.io/gh/PaddleHQ/python-aws-ssm) |
| 3 | +[](https://opensource.org/licenses/Apache-2.0) |
2 | 4 | <a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a> |
3 | | -Python package that interfaces with AWS System Manager |
| 5 | + |
| 6 | +# python-aws-ssm |
| 7 | +Python package that interfaces with [AWS System Manager](https://www.amazonaws.cn/en/systems-manager/). |
| 8 | + |
| 9 | +## Why to use python-aws-ssm and not the aws-sdk-go? |
| 10 | +This package is wrapping the aws-sdk-go and hides the complexity dealing with the not so Python friendly AWS SDK. |
| 11 | +Perfect use case for this package is when secure parameters for an application are stored to |
| 12 | +[AWS Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html) |
| 13 | +using a path hierarchy. During application startup you can use this package to fetch them and use them in your application. |
| 14 | + |
| 15 | +## Install |
| 16 | +```bash |
| 17 | +pip install python-aws-ssm |
| 18 | +``` |
| 19 | + |
| 20 | +## Examples |
| 21 | + |
| 22 | +#### Basic Usage |
| 23 | + |
| 24 | +```python |
| 25 | +from python_aws_ssm.parameters import ParameterStore |
| 26 | + |
| 27 | +# Assuming you have the parameters in the following format: |
| 28 | +# my-service/dev/param-1 -> with value `a` |
| 29 | +# my-service/dev/param-2 -> with value `b` |
| 30 | +parameter_store = ParameterStore() |
| 31 | +# Requesting the base path |
| 32 | +parameters = parameter_store.get_parameters_by_path("/my-service/dev/") |
| 33 | +# And getting a specific value |
| 34 | +value = parameters.get("param-1") |
| 35 | +# value should be `a` |
| 36 | +``` |
| 37 | + |
| 38 | +#### Recursive and nested options |
| 39 | + |
| 40 | +```python |
| 41 | +from python_aws_ssm.parameters import ParameterStore |
| 42 | + |
| 43 | +# Assuming you have the parameters in the following format: |
| 44 | +# my-service/dev/param-1 -> with value `a` |
| 45 | +# my-service/dev/param-2 -> with value `b` |
| 46 | +parameter_store = ParameterStore() |
| 47 | +# Requesting the base path |
| 48 | +parameters = parameter_store.get_parameters_by_path( |
| 49 | + "/my-service/", recursive=True, nested=True |
| 50 | +) |
| 51 | +# And getting a specific value |
| 52 | +dev_parameters = parameters.get("dev") |
| 53 | +# value should be {"param-1": "a", "param-2": "b"} |
| 54 | +``` |
| 55 | + |
| 56 | +#### Get parameters by name |
| 57 | + |
| 58 | +```python |
| 59 | +from python_aws_ssm.parameters import ParameterStore |
| 60 | + |
| 61 | +# Assuming you have the parameters in the following format: |
| 62 | +# my-service/dev/param-1 -> with value `a` |
| 63 | +# common/dev/param-2 -> with value `b` |
| 64 | +parameter_store = ParameterStore() |
| 65 | +# Requesting the base path |
| 66 | +parameters = parameter_store.get_parameters( |
| 67 | + ["/my-service/dev/param-1", "/common/dev/param-2"] |
| 68 | +) |
| 69 | +# And getting a specific value |
| 70 | +dev_parameters = parameters.get("/common/dev/param-2") |
| 71 | +# value should be `b` |
| 72 | +``` |
0 commit comments