Skip to main content

SSM AppConfig Storage Helper

Project description

ssmash

https://img.shields.io/pypi/v/ssmash.svg Python versions Documentation Status Downloads Code style: black

ssmash, the SSM AppConfig Storage Helper, is an easy-to-use application configuration management tool for AWS deployments. You specify hierarchical configuration values in a simple YAML file, and ssmash will turn that into an AWS CloudFormation file that stores your configuration values in the SSM Parameter Store.

Installation

Install ssmash using pip, the standard python package installer:

$ pip install ssmash

You will probably use ssmash with the AWS command line tools, so install and configure that too, if you haven’t already:

$ pip install awscli
$ aws configure

Example

Suppose you have an input file like this:

acme:
    shipping-labels-service:
        enable-fast-delivery: true
        explosive-purchase-limit: 1000
        greeting: hello world
        whitelist-users:
            - coyote
            - roadrunner

Then run ssmash:

$ ssmash -i acme_prod_config.yaml -o cloud_formation_template.yaml
$ aws cloudformation deploy \
    --stack-name "acme-prod-config" --template-file cloud_formation_template.yaml \
    --no-fail-on-empty-changeset

You will now have the following parameters in AWS Systems Manager, that can be loaded as a string inside your application:

  • /acme/shipping-labels-service/enable-fast-delivery = “true”

  • /acme/shipping-labels-service/explosive-purchase-limit = “1000”

  • /acme/shipping-labels-service/greeting = “hello world”

  • /acme/shipping-labels-service/whitelist-users = “coyote,roadrunner”

Automated Application Restarts

Most of the time, your application loads its configuration at startup. Depending on your application, the safest and easiest way to reload its configuration is to simply restart it.

ssmash has built-in support to restart some types of application as part of the deployment process. We do this by telling it to “invalidate” the configuration used by the application.

Docker with AWS ECS

ssmash can generate CloudFormation that will safely restart the Tasks in an ECS Service once your configuration has changed, and make the successful deployment of your new application configuration depend upon the successful restart of that Service. Just specify the target ECS service using extra command line parameters, like so:

$ ssmash -i acme_prod_config.yaml -o cloud_formation_template.yaml \
    invalidate-ecs \
    --cluster-name acme-prod-cluster \
    --service-name shipping-labels-service \
    --role-name arn:aws:iam::123456789012:role/acme-ecs-admin
$ aws cloudformation deploy \
    --stack-name "acme-prod-config" --template-file cloud_formation_template.yaml \
    --no-fail-on-empty-changeset

You can also refer to the name of a CloudFormation Export instead of using the name directly (eg. if your service has a non-obvious generated name), using the interchangeable command line parameters for --cluster-import and --service-import and --role-import.

Serverless with AWS Lambda

ssmash can generate CloudFormation that will safely cause your serverless functions to discard their virtual machine (aka “Execution Context”), meaning they effectively reload their configuration. To access this secret sauce, just add a couple more command line parameters:

$ ssmash -i acme_prod_config.yaml -o cloud_formation_template.yaml \
    invalidate-lambda \
    --function-name shipping-label-printer-function \
    --role-name arn:aws:iam::123456789012:role/acme-serverless-admin
$ aws cloudformation deploy \
    --stack-name "acme-prod-config" --template-file cloud_formation_template.yaml \
    --no-fail-on-empty-changeset

You can also refer to the name of a CloudFormation Export instead of using the name directly, using the interchangeable command line parameters for --function-import and --role-import.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

v2.1.1 (2019-11-29)

Fixed: * Update versions for dependencies

v2.1.0 (2019-11-28)

Added:

  • Be able to invalidate a single Lambda Function

Fixed: * Update versions for dependencies to be “compatible”

v2.0.1 (2019-06-28)

Fixed:

  • Couldn’t run script

v2.0.0 (2019-06-28)

Changed:

  • #22 : Change command line API so that the input and output files are options, rather than arguments.

  • #22 : Change command line API so that invalidating an ECS Service is done through a chained sub-command, rather than additional options.

Added:

  • #8 : Support lists of plain values, which are stored as a SSM StringList parameter

Removed:

  • You can’t specify input and output files as positional arguments any more. Use –input-file FILENAME and –output-file FILENAME instead.

  • The –invalidate-ecs-service and –invalidation-role options have been replaced with the invalidate-ecs command.

v1.1.0 (2019-06-05)

Added:

  • Be able to automatically invalidate an existing ECS Service as part of the parameter deployment, so that it picks up the new configuration.

v1.0.0 (2019-05-30)

v1.0.0-rc1 (2019-05-24)

Added:

  • ssmash script to create String SSM Parameters from a simple config file stored in YAML

  • Basic documentation in README

v0.1.0 (2019-05-14)

Added:

  • First release on PyPI.

  • Cookiecutter skeleton only, no functionality

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

ssmash-2.1.1.tar.gz (34.9 kB view hashes)

Uploaded Source

Built Distribution

ssmash-2.1.1-py2.py3-none-any.whl (24.6 kB view hashes)

Uploaded Python 2 Python 3

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