A simple CLI and Library for adding/removing/renaming/copying AWS Param Store Parameters
Project description
Note
Version 1 of this library is drastically different than previous versions. The CLI Application hasn't changed but the library it uses has. Please pay extra attention to the examples below or look at the underlying class for more information.
Why this script?
The current (Jul 2017) AWS Console for the Systems Manager Parameter
Store is good for adding and editing the values of parameters, but
misses key productivity functions like copying (especially en mass),
renaming, etc. The current aws ssm
CLI is very similar in
functionality to the AWS Console.
This script is to automate a lot of the manual work currently needed with the existing AWS-provided UIs.
Docs
Full documentation can be found here: https://awsparams.readthedocs.io/en/latest/
Installation
- AWSParams requires Python 3.6+
- Depending on your Python3.6 install either
pip install awsparams
orpip3 install awsparams
- If you're on windows, make sure that
C:\Users\{your user}\AppData\Roaming\Python\{your python version}\Scripts
has been added to your user path.
- If you're on windows, make sure that
Usage
Library:
from awsparams import AWSParams
# Using default Profile
aws_params = AWSParams()
# Using a Custome Profile
aws_params = AWSParams('MyProfile')
#get a single parameter
param = get_parameter('test1')
# ParamResult(Name='test1', Value='test123', Type='SecureString')
#ParamResult is a named tuple with properties Name, Value, Type
param.Name # 'test1'
param.Value # 'test123'
param.Type # 'SecureString'
# get multiple parameters with a prefix
params = get_all_parameters(prefix="testing.testing.")
# [ParamResult(Name='testing', Value='1234', Type='String'),
# ParamResult(Name='testing2', Value='1234', Type='String')]
# get multiple parameters by path
params = get_all_parameters(prefix="/testing/testing/", by_path=True)
# [ParamResult(Name='testing', Value='1234', Type='String'),
# ParamResult(Name='testing2', Value='1234', Type='String')]
# get multiple parameters by path
params = get_all_parameters(prefix="/testing/testing/", by_path=True, trim_name=False)
# [ParamResult(Name='/testing/testing/testing', Value='1234', Type='String'),
# ParamResult(Name='/testing/testing/testing2', Value='1234', Type='String')]
# get just a parameter value
value = get_parameter_value('test1')
# test123
For more detailed examples of usage as a library see the cli implementation here.
CLI application:
Usage can be referenced by running awsparams --help
or awsparams subcommand --help
commands:
Usage: awsparams [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
cp Copy a parameter, optionally across accounts
ls List Paramters, optional matching a specific...
mv Move or rename a parameter
new Create a new parameter
rm Remove/Delete a parameter
set Edit an existing parameter
Command Examples
ls usage
ls names only: awsparams ls
ls with values no decryption: awsparams ls --values
or awsparams ls -v
ls with values and decryption: awsparams ls --with-decryption
ls by prefix: awsparams ls appname.prd
ls with values, formatted for using in a Jetbrains run configuration: awsparams ls -r <prefix>
or awsparams ls --jetbrains-run-config <prefix>
ls with values, formatted for using in a .env
file: awsparams ls -e <prefix>
or awsparams ls --dot-env <prefix>
ls with values, formatted for using in a .tfvars
file: awsparams ls -t <prefix>
or awsparams ls --tfvars <prefix>
For the above two options, add the -q
or --esc-quotes
flag for adding \
in front of any quotation marks in
the values, such as in stringify-ed JSON objects. Most .env
file parsers don't require this, but .tfvars
probably does.
Add the --delimiter <delimiter>
(or -d <delimiter>
) option to override the default delimiter (/
), if necessary.
new usage
new interactively: awsparams new
new semi-interactively: awsparams new --name appname.prd.username
new non-interactive: awsparams new --name appname.prd.usrname --value parameter_value --description parameter_descripton
cp usage
copy a parameter: awsparams cp appname.prd.username newappname.prd.username
copy set of parameters with prefix appname.dev. to appname.prd.: awsparams cp appname.dev. appname.prd. --prefix
copy set of parameters starting with prefix repometa-generator.prd
overwrite existing parameters accross different accounts: awsparams cp repometa-generator.prd --src_profile=dev --dst_profile=trn --prefix=True
copy single parameters accross different accounts: awsparams cp appname.dev.username appname.trb.us
Contributing
To contribute:
- Make a PR to master
- In your changes, make sure to manually bump the package version in the
pyproject.toml
file to whatever version you think is appropriate.
- In your changes, make sure to manually bump the package version in the
- Once the PR is approved, merge it in to master.
- Create a new release and a new tag where the version in the tag is equal to the new version you set in the
pyproject.toml
file. - Once you publish the release, check the GitHub actions and notice that it is automatically deploying the package.
- Confirm that the deploy succeeds.
- If anything goes wrong, fix it and then re-run the workflow.
- You may have to delete your release/tag and recreate it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file awsparams-1.5.5.tar.gz
.
File metadata
- Download URL: awsparams-1.5.5.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68075e63eb4d4ab515ab55ea6b2b52247f5699f01ceab0a430ae5b343771b4b2 |
|
MD5 | 01dbe422580c20e80e66b475a6229afd |
|
BLAKE2b-256 | 608d6ffd51a8754eb65f082edf26b1725ca9367299bb44e5bc49bcca6fdacc37 |
File details
Details for the file awsparams-1.5.5-py3-none-any.whl
.
File metadata
- Download URL: awsparams-1.5.5-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ac3395c162588cababfd1bb372dca00bf74dcc2a31374db2eff07a083b346e4 |
|
MD5 | e8e528f1d5609dcc87452f66d23c423c |
|
BLAKE2b-256 | 1506dd03e686acaa22410d420443651156120852f5358109ff30f54ce6dbaa46 |