# Fetch secrets from AWS Secrets Manager similar to env-consul
## Usage
```shell
usage: secrets-env [-h] [-p PREFIX] [-m] [--stdin STDIN] [-e] [-u | -l] secret [secret ...]
Return one or more secrets by either name or pattern, using Unix style glob matching. When using glob style matches then all secret names that
match the pattern will be returned. When using stdin and specifying options per pattern the options will be applied to the first match whereas multiple secrets
supplied as positional args will have the options provided as commandline arguments applied to all of them.
positional arguments:
secret
options:
-h, --help show this help message and exit
-p PREFIX, --prefix PREFIX
Prepend a prefix to each value
-m, --merge-keys Merge all secrets into one object. Secrets that are simple strings will have the last segment of their name (characters following the last /) as they key.
--stdin STDIN Read secret options from stdin. See details below for more info.
When using stdin, a subset of arguments are taken as lowercase strings matching the long version of argument names and separated by a pipe. You don't actually have to use this argument to use stdin.
Technically just passing data on stdin is enough.
Example:
echo 'myvar | upper | prefix TF_VAR_;' | secrets-env -
This is the equivalent of passing -u -p TF_VAR_ myvar as commandline arguments. Note the ending '-'. Multiple secrets are supported, with each
one taking its own set of arguments and separated by a semi-colon.
-e, --env Format output as env vars for a shell to consume
-u, --upper Cast secret names to upper case. Does not apply to prefixes.
-l, --lower Cast secret names to lower case. Does not apply to prefixes.
```
## Examples
### Basic example
```shell
~ > secrets-env -m mmoon-test/1 mmoon-test/2
{
"test1": "test1val",
"test2": "test2val"
}
```
### Returning TF input variables
```shell
~ > secrets-env -m -e -p TF_VAR_ mmoon-test/1 mmoon-test/2
TF_VAR_test1=test1val
TF_VAR_test2=test2val
```
### Passing args on stdin
You can pass multiple secrets on stdin, each with their own flags for `--upper`, `--lower`, or `--prefix`. `--merge-keys` and `--env` are always set os commandline flags and will be ignored if set on stdin. Note the `-` delimiting the end of arg input. This tells secrets-env that commandline args have ended and to start reading from stdin.
```shell
echo '
mmoon-test/1 | upper | prefix MY_PREFIX_;
mmoon-test/2 | lower | prefix stay_lower_prefix_;
' | secrets-env -me -
MY_PREFIX_MMOON_TEST_1=test1val
stay_lower_prefix_test=test2val
```
Raw data
{
"_id": null,
"home_page": "https://github.com/mathewmoon/aws-secrets-env",
"name": "aws-secrets-env",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.12,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Mathew Moon",
"author_email": "me@mathewmoon.net",
"download_url": "https://files.pythonhosted.org/packages/ae/28/6fdb9675315249d4a9a0abd2e97112550c14d1c5f23a11735cd438129051/aws_secrets_env-0.1.2.tar.gz",
"platform": null,
"description": "# Fetch secrets from AWS Secrets Manager similar to env-consul\n\n## Usage\n```shell\nusage: secrets-env [-h] [-p PREFIX] [-m] [--stdin STDIN] [-e] [-u | -l] secret [secret ...]\n\nReturn one or more secrets by either name or pattern, using Unix style glob matching. When using glob style matches then all secret names that\nmatch the pattern will be returned. When using stdin and specifying options per pattern the options will be applied to the first match whereas multiple secrets\nsupplied as positional args will have the options provided as commandline arguments applied to all of them.\n\npositional arguments:\n secret\n\noptions:\n -h, --help show this help message and exit\n -p PREFIX, --prefix PREFIX\n Prepend a prefix to each value\n -m, --merge-keys Merge all secrets into one object. Secrets that are simple strings will have the last segment of their name (characters following the last /) as they key.\n --stdin STDIN Read secret options from stdin. See details below for more info.\n\n When using stdin, a subset of arguments are taken as lowercase strings matching the long version of argument names and separated by a pipe. You don't actually have to use this argument to use stdin.\n Technically just passing data on stdin is enough.\n Example:\n\n echo 'myvar | upper | prefix TF_VAR_;' | secrets-env -\n\n This is the equivalent of passing -u -p TF_VAR_ myvar as commandline arguments. Note the ending '-'. Multiple secrets are supported, with each\n one taking its own set of arguments and separated by a semi-colon.\n\n -e, --env Format output as env vars for a shell to consume\n -u, --upper Cast secret names to upper case. Does not apply to prefixes.\n -l, --lower Cast secret names to lower case. Does not apply to prefixes.\n```\n\n## Examples\n\n### Basic example\n```shell\n~ > secrets-env -m mmoon-test/1 mmoon-test/2\n{\n \"test1\": \"test1val\",\n \"test2\": \"test2val\"\n}\n```\n\n### Returning TF input variables\n```shell\n~ > secrets-env -m -e -p TF_VAR_ mmoon-test/1 mmoon-test/2\nTF_VAR_test1=test1val\nTF_VAR_test2=test2val\n```\n\n### Passing args on stdin\nYou can pass multiple secrets on stdin, each with their own flags for `--upper`, `--lower`, or `--prefix`. `--merge-keys` and `--env` are always set os commandline flags and will be ignored if set on stdin. Note the `-` delimiting the end of arg input. This tells secrets-env that commandline args have ended and to start reading from stdin.\n```shell\necho '\nmmoon-test/1 | upper | prefix MY_PREFIX_;\nmmoon-test/2 | lower | prefix stay_lower_prefix_;\n' | secrets-env -me -\n\nMY_PREFIX_MMOON_TEST_1=test1val\nstay_lower_prefix_test=test2val\n```\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Fetch AWS secrets in a way similar to consul-env",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/mathewmoon/aws-secrets-env",
"Repository": "https://github.com/mathewmoon/aws-secrets-env"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eacd085894174970a9da07d03711e2147e5b374a522a7dd0b5b348c17fd8c192",
"md5": "af4ff179ec2482580e0611a285471f5e",
"sha256": "e9dbc99254cc410667a8224ef359f1288a30e17d8207ede5e657530e53f3705b"
},
"downloads": -1,
"filename": "aws_secrets_env-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af4ff179ec2482580e0611a285471f5e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12,<4.0",
"size": 7126,
"upload_time": "2024-03-12T18:06:48",
"upload_time_iso_8601": "2024-03-12T18:06:48.828156Z",
"url": "https://files.pythonhosted.org/packages/ea/cd/085894174970a9da07d03711e2147e5b374a522a7dd0b5b348c17fd8c192/aws_secrets_env-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae286fdb9675315249d4a9a0abd2e97112550c14d1c5f23a11735cd438129051",
"md5": "1b4e0c5a2a5339e69f57ae6e029b4b66",
"sha256": "a44dc3b4e7503ee3c4b7b628808a4ffaa90d271f2827f39085d8e7004ce8725e"
},
"downloads": -1,
"filename": "aws_secrets_env-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "1b4e0c5a2a5339e69f57ae6e029b4b66",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12,<4.0",
"size": 5565,
"upload_time": "2024-03-12T18:06:50",
"upload_time_iso_8601": "2024-03-12T18:06:50.337675Z",
"url": "https://files.pythonhosted.org/packages/ae/28/6fdb9675315249d4a9a0abd2e97112550c14d1c5f23a11735cd438129051/aws_secrets_env-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-12 18:06:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mathewmoon",
"github_project": "aws-secrets-env",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aws-secrets-env"
}