Skip to main content

AWS SSM parameter store utility.

Project description

Confetti

Confectionary confetti to confine those confounded configurations confidently

Install in your application

$ pip install git+ssh://git@github.com/AmberEngine/confectionary-confetti.git#egg=confectionary-confetti

Create a boto3 session. If you don't create a session, one will be created for you using your AWS user configuration or role.

The session keyword argument overrides the default session.

    from confetti import Confetti
    
    session = boto3.session.Session()
    confetti = Confetti(session=session)
    
    print(confetti.path)

Output

/Development/Confetti

Choose a key. Your key will the root of the namespacing path of your application's parameters and will be used as an alias for a KMS key to encrypt and decrypt your parameters. If you don't choose a key, the default value is 'Development'.

Set CONFETTI_KEY environment variable. The CONFETTI_KEY environment overrides the default.

$ export CONFETTI_KEY=YourKey
    from confetti import Confetti
    
    confetti = Confetti()
    
    print(confetti.path)

Output

/YourKey/Confetti

The confetti_key keyword argument overrides the CONFETTI_KEY environment variable.

    from confetti import Confetti
    
    confetti = Confetti(confetti_key='YourKey')
    
    print(confetti.path)

Output

/YourKey/Confetti

Choose a path. Your path will be appended to the namespacing path of your application's parameters, i.e. /<confetti_key>/<confetti_path>. e.g. /YourKey/Your/Path. If you don't choose a path, the default value is the name of the Confetti class.

Override the Confetti class and use MyApp as the default.

    from confetti import Confetti
    
    class MyApp(Confetti):
        pass
    
    confetti = MyApp()
    
    print(confetti.path)

Output

/Development/MyApp

Set CONFETTI_PATH environment variable. The CONFETTI_PATH environment overrides the default.

$ export CONFETTI_PATH=Your/Path
    from confetti import Confetti
    
    confetti = Confetti()
    
    print(confetti.path)

Output

/Development/Your/Path

The confetti_path keyword argument overrides the CONFETTI_PATH environment variable.

    from confetti import Confetti
    
    confetti = Confetti(confetti_path='Your/Path')
    
    print(confetti.path)

Output

/Development/Your/Path

Retrieve and use your parameters in your application. Note that it is assumed that your SecureString parameters are to be retrieved with decryption. You can override the parameters to SSM.Client.get_parameters_by_path via keyword arguments with the exception of 'Path'.

    from confetti import Confetti

    confetti = Confetti(confetti_key="Production", confetti_path="MyApp")
    parameters = confetti.get_parameters()

    # Print the value of a specific parameter
    print(parameters.APP_URL)

    # Print your parameters
    print(parameters)

Store parameters from a JSON file.

Create a JSON file with your new parameters

[{
    "Name": "APP_URL",
    "Value": "http://www.mrcoolice.com/app",
    "Type": "String"
}, {
    "Name": "APP_KEY",
    "Value": "abcde12345",
    "Type": "SecureString"
}, {
    "Name": "THINGS",
    "Value": "thing1, thing2",
    "Type": "StringList"
}]

Export your current parameters to a JSON file so you can modify them. Note that it is assumed that your SecureString parameters are to be retrieved with decryption. You can override the parameters to SSM.Client.get_parameters_by_path via keyword arguments with the exception of 'Path'.

    from confetti import Confetti

    # Create your app's config
    confetti = Confetti(confetti_key="Production", confetti_path="MyApp")

    # Export to JSON from AWS SSM parameter store
    confetti.export_parameters("parameters.json")

Review and modify your parameters.

[{
    "Name": "APP_URL",
    "Value": "http://www.mrcoolice.com/app",
    "Type": "String",
    "Overwrite": true
}, {
    "Name": "APP_KEY",
    "Value": "abcde12345",
    "Type": "SecureString",
    "Overwrite": true
}, {
    "Name": "THINGS",
    "Value": "thing1, thing2",
    "Type": "StringList",
    "Overwrite": true
}]

Set your parameters for your application. Do this only once and your parameters will be stored in your AWS SSM Parameter Store.

    from confetti import Confetti

    # Create your app's config
    confetti = Confetti(confetti_key="Production", confetti_path="MyApp")

    # Import parameters from JSON to AWS SSM parameter store
    confetti.import_parameters("parameters.json")

see also: AWS Systems Manager Parameter Store and SSM.Client.put_parameter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confectionary-confetti-0.0.1.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file confectionary-confetti-0.0.1.tar.gz.

File metadata

  • Download URL: confectionary-confetti-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for confectionary-confetti-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5796a53e3651ab2ece29b5520ab687455745ce28dde982347160750f0b21b336
MD5 d24dc0e5f931d84632640ed7051aeffa
BLAKE2b-256 739d6976257b5299af27a28eec47cbe4ae4689747630c247b46b453e5f4304b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page