Skip to content

Attach the label latest when AWS SSM Parameter is created or updated

License

Notifications You must be signed in to change notification settings

unfor19/ssm-label

Repository files navigation

ssm-label

License: MIT

Attach the label latest when AWS SSM Parameter is created or updated. Especially useful for applications which load AWS SSM Parameters on startup.

Getting Started

Deploy

IMPORTANT ssm-label works per region, so deploy it in each reason that you need to use it

Launch in Virginia Virginia us-east-1

Launch in Ireland Ireland eu-west-1

Launch in Hong Kong Hong Kong ap-east-1

Launch in Canada Canada ca-central-1

More regions

To deploy in other regions, replace AWS_REGION with the region's code

https://AWS_REGION.console.aws.amazon.com/cloudformation/home?region=AWS_REGION#/stacks/quickcreate?templateURL=https://
ssm-label.s3-eu-west-1.amazonaws.com/cfn-template-ssm-label.yml

Use in your application

On startup, use AWS SDK and fetch all parameters, filter by label latest, save the results to a global variable (or a Singleton) and use it across your application.

Need to rollback to a previous Parameter version?

  1. Go to your AWS Console
  2. Systems Manager > Parameter Store > Click on relevant Parameter
  3. History tab > Click on relevant version > Click Attach labels button
  4. Add another label > Type latest > A good warning - Moving from version # > Confirm

Examples

  • Requires ssm-label to be deployed in your AWS account

  • Assuming that AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set, or that you're using some other credentials provider, for example, aws configure

  • Both examples rely on the following environment variables

    VARNAME=DEFAULT_VALUE
    PARAMETERS_PATH=(Required)
    PARAMETERS_NON_RECURSIVE=''
    PARAMETERS_NO_DECRYPTION=''
    PARAMETERS_MAX_RESULTS=10 # used in pagination, keep it as 10

Python

  • Requires Python 3.6+ and boto3 pip install boto3
  • Execute
    $ bash examples/python_example.sh

NodeJS

Limitations

  1. It takes up to 30 seconds for the label latest to be attached - the Lambda Function which attaches the label runs for about ~1sec, but it takes time for it to be triggered by the CloudWatch Event
  2. There's a limit of 100 versions per parameter - AWS hard limit, see Upcoming Features below ssm-cleanup

Upcoming Features

  1. Lambda Function, ssm-cleanup runs once a day to clean up all parameters which have more than 30 versions, cleans up the first 20 versions, and ignores versions with labels
  2. Lambda Function, ssm-slack sends a message to a Slack channel with the information about the change - actor, parameter name and version

Contributing

Report issues/questions/feature requests on the Issues section.

Pull requests are welcome! Ideally, create a feature branch and issue for every single change you make. These are the steps:

  1. Fork this repo
  2. Create your feature branch from master (git checkout -b my-new-feature)
  3. Add the code of your new feature
  4. Commit your remarkable changes (git commit -am 'Added new feature')
  5. Push to the branch (git push --set-up-stream origin my-new-feature)
  6. Create a new Pull Request and tell us about your changes

Authors

Created and maintained by Meir Gabay

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Attach the label latest when AWS SSM Parameter is created or updated

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published