Tips and tricks for AWS SSM Parameter Store with confd

If there issues in the config templates or perhaps you are referencing non existing keys, confd will fail with an error and your container won’t start.Export dotenv to environment variablesIf you application relies on environment variables you can still generate a dotenv file and export the variables with a simple command before starting the application.export $(cat .env | xargs)Using confd for more complex filesConfd is not limited to create only dotenv files, it can handle more complex data types it can loop through keys, you can use filters on the keys or values..In the linked repository above there is an example on creating a yaml file by looping through all keys under /client-api/database.database:{{- range gets "/client-api/database/*"}} {{ .Key | base }}: {{.Value}}{{- end}}Which will result in:database: password: p@ssw0rd user: clientFinal thoughtsAWS SSM parameter store makes it very easy to store and version parameters and secrets..You can of course set up your own etcd or consul, but once you are in the AWS ecosystem you can save some time if you use their solution.Setting variables with the AWS CLI is simple, but doesn’t scale too well compared to confd..The CLI also takes up much more space, which might not be a problem if you are running on virtual machines but if you are using containers you probably want to keep them small..Check out the github repo above, it builds two images based on alpine linux, one with the CLI and one with confd..The confd binary is less than 6MB whereas for the AWS CLI you need python and it takes about a 100MB more space.REPOSITORY TAG SIZEssm-confd_confd latest 10.8MBssm-confd_awscli latest 110MBWith confd you can write as complex configuration files as you want or can just stick with a basic dotenv, it’s up to you..It’s a very handy tool at a platform engineer’s toolkit and couple with SSM it makes your life a lot easier to deploy to different environments.. More details

Leave a Reply