\n\n# ssmx\n\n`ssmx` is a CLI tool for injecting parameters stored in AWS SSM into executables.\n\nIt also provides commands to retrieve and set parameters in AWS SSM.\n\n## Installation\n\n```\npip install ssmx\n```\n\n## Usage\n\nRunning:\n\n```\nssmx --help\n```\n\n## Configuring Credentials\n\nThe Following authentication methods are supported:\n\n- Environment variables\n- Shared credential file (~/.aws/credentials)\n- AWS config file (~/.aws/config)\n- AWS profiles\n\nFor more details please see [here](http://boto3.readthedocs.io/en/latest/guide/configuration.html).\n\n### List parameters\n\nList all parameters:\n\n```\nssmx list\n```\n\nOutput:\n\n```\n+------------------------------------+---------------+\n| Name | Description |\n+====================================+===============+\n| /platform/infra/testing | Test param |\n+------------------------------------+---------------+\n| MY_KEY | MY TEST KEY |\n+------------------------------------+---------------+\n```\n\nFilter parameters by name:\n\n```\nssmx list --name my-app\n```\n\nWill list parameters starting with `my-app`\n\n```\n+---------------------+----------------------+\n| Name | Description |\n+=====================+======================+\n| my-app.hostname | my app hostname |\n| my-app.secret-key | hush puppy |\n+---------------------+----------------------+\n```\n\n### Delete Parameters\n\n```\nssmx delete --name \n```\n\nWill delete the parameter `MY_KEY`. Invalid parameters are ignored and printed on stdout.\n\nOutput:\n\n```\n+----------------------+\n| Deleted Parameters |\n+======================+\n| MY_KEY |\n+----------------------+\n```\n\n### Get parameters\n\n```bash\nssmx get --name \n```\n\nWill retrieve and decrypt the param MY_KEY\nOutput:\n\n```\n+--------+---------+\n| Name | Value |\n+========+=========+\n| MY_KEY | MY_VAL |\n+--------+---------+\n```\n\n### Put parameters\n\n```bash\nssmx put\n--name \n--value \n--description # optional\n--encrypt # optional\n--key-id # required only when --encrypt is specified\n```\n\n**Important Note:** `put` behaves like an upsert, meaning if no entry exists with the name provided, it will create a new entry, and if an entry already exists with the name provided, it will overwrite the current value with the value provided.\n\n### Provide env variables to an executable\n\n```\nssmx exec --env-file -- \n```\n\nUsing the `exec` command, you can specify an `env` file that contains plain and secret values. Secret values need to be provided in the following format:\n\n```bash\nPLAIN_ENV_VAR=hello world\nSECRET_ENV_VAR=ssm:\n```\n\n#### Example\n\nLet's assume we are working with a node.js application that requires specific secret envrionment variables for specific environments. In other words, our application depends on `.env` files to contain the environment variables it needs to function correctly for each environment it's deployed in.\n\nSuppose our `dev.env` file looks like the following\n\n```bash\nTHIRD_PARTY_HOSTNAME=https://api.third-party.com\nTHIRD_PARTY_ACCESS_TOKEN=ssm:my-app.dev-third-party-access-token\n```\n\nWe now need to pass this `dev.env` file to `ssmx` to fetch and decrypt the value for `THIRD_PARTY_ACCESS_TOKEN` and then inject the two env. variables into the process that will run our node.js application.\n\n```bash\n$ ssmx exec --env-file ./env/dev.env -- npm start\n```\n\n#### Example with --name parameter\n\nLet's simplify our example from above and let's assume we store all our plain and secret env. variables in AWS SSM and we don't use `.env` files.\n\nWe also prefix our keys in AWS SSM with `-my-app`, i.e.\n\n```\n+--------------------------------------+------------------------------+\n| Name | Value |\n+======================================+==============================+\n| /dev-my-app/third-party-hostname | https://api.third-party.com |\n| /dev-my-app/third-party-access-token | shhhh-my-access-token |\n+--------------------------------------+------------------------------+\n```\n\nWe can then acheive the same result in the previous example with the following command\n\n```bash\n$ ssmx exec --name dev-my-app -- npm start\n```\n\nNow this feature is really handy because if you're using docker to containerize your applications and AWS ECS to host your containers, you can simply provide an environment variable in your container definition, (i.e. `APP_NAME` ) to differentiate between each environment.\n\nFor example, in our Dockerfile we can do the following \n\n```docker\nENTRYPOINT [ \"./run-app.sh\" ]\n```\n\n./run-app.sh\n\n```bash\n#!/usr/bin/env bash\nset -e\necho \"Starting up...\"\n\n# $APP_NAME is exposed by the container definition \nssmx exec --name $APP_NAME -- npm start\n```\n\n#### Important Note\n\nIf you plan to use the `--name` parameter with `ssmx exec`, you need to follow a specific format for the keys you create in AWS SSM. The keys need to follow the `path` format which works as follows:\n\n```bash\n///.../\n\n# examples\n/my-app/third-party-hostname\n/my-app/dev/third-party-hostname\n```\n\nYou can read in more detail about paths [here](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParametersByPath.html#systemsmanager-GetParametersByPath-request-Path)\n\n### License\n\n`ssmx` is released under [MIT](./LICENSE)\n\n### Inspirations\n\nThis project is a fork from HelloFresh's [ssm-cli](https://github.com/hellofresh/ssm-cli) and drew inspiration from the following projects:\n\n- [Chamber](https://github.com/segmentio/chamber)\n- [kms-env](https://github.com/ukayani/kms-env)\n- [dotenv](https://github.com/theskumar/python-dotenv)",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "https://github.com/JetJet13/ssmx/archive/v1.0.2.tar.gz",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/JetJet13/ssmx",
"keywords": "",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "ssmx",
"package_url": "https://pypi.org/project/ssmx/",
"platform": "",
"project_url": "https://pypi.org/project/ssmx/",
"project_urls": {
"Download": "https://github.com/JetJet13/ssmx/archive/v1.0.2.tar.gz",
"Homepage": "https://github.com/JetJet13/ssmx"
},
"release_url": "https://pypi.org/project/ssmx/1.0.3/",
"requires_dist": null,
"requires_python": ">=2.7",
"summary": "CLI tool for injecting parameters stored in AWS SSM into executables.",
"version": "1.0.3"
},
"last_serial": 4928369,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "d5047b6f5a3ee976d83eb61dccea07bf",
"sha256": "72f52e3f2ab5152ebd38d3eeaeb489c644a000d67e2a672a850f9bca36847487"
},
"downloads": -1,
"filename": "ssmx-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "d5047b6f5a3ee976d83eb61dccea07bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5614,
"upload_time": "2018-12-16T03:17:52",
"url": "https://files.pythonhosted.org/packages/98/ef/76db3bd15789d533de9b9e4789d9bb96ec147dda48628a3f6adebf365458/ssmx-1.0.0.tar.gz"
}
],
"1.0.1": [
{
"comment_text": "",
"digests": {
"md5": "6369e1078b3d0e1d42e9b5d830e21782",
"sha256": "d520e3591b88cb371f2e4d4c1f2170ef6d28d155cbacedfa3deba07685955ab0"
},
"downloads": -1,
"filename": "ssmx-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6369e1078b3d0e1d42e9b5d830e21782",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 6420,
"upload_time": "2018-12-16T03:33:37",
"url": "https://files.pythonhosted.org/packages/d0/35/f5e8c156c11c9e8e56e323d0a434de9cd904f02481ea6742b53b9836b230/ssmx-1.0.1.tar.gz"
}
],
"1.0.2": [
{
"comment_text": "",
"digests": {
"md5": "27b6cbbaa046f825a182d0bc7f0b158e",
"sha256": "9094abe096cc8a779c2d125ba92488ed8bd7a0b50d25e67ae9be30c5f10a14ac"
},
"downloads": -1,
"filename": "ssmx-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "27b6cbbaa046f825a182d0bc7f0b158e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 6485,
"upload_time": "2018-12-16T03:40:47",
"url": "https://files.pythonhosted.org/packages/59/5b/9e21cae4a0e7420b84417abcbd51d0280e3cb58b09f2d9f2333b46afa889/ssmx-1.0.2.tar.gz"
}
],
"1.0.3": [
{
"comment_text": "",
"digests": {
"md5": "44ad8e210e77d2ff5df9b21f104e8ca5",
"sha256": "21692e3942de13514a6c42b5671c204a0df9768d4d06768aa5ad296405ca6665"
},
"downloads": -1,
"filename": "ssmx-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "44ad8e210e77d2ff5df9b21f104e8ca5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 6302,
"upload_time": "2019-03-12T04:54:33",
"url": "https://files.pythonhosted.org/packages/ef/b8/8b8600bd04f7a259d44fa51d44ed3aa18fa74e36c71ca7c37b71e2931784/ssmx-1.0.3.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "44ad8e210e77d2ff5df9b21f104e8ca5",
"sha256": "21692e3942de13514a6c42b5671c204a0df9768d4d06768aa5ad296405ca6665"
},
"downloads": -1,
"filename": "ssmx-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "44ad8e210e77d2ff5df9b21f104e8ca5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 6302,
"upload_time": "2019-03-12T04:54:33",
"url": "https://files.pythonhosted.org/packages/ef/b8/8b8600bd04f7a259d44fa51d44ed3aa18fa74e36c71ca7c37b71e2931784/ssmx-1.0.3.tar.gz"
}
]
}