Shortening feedback loops with ‘sls print’
Recently I’ve been doing some work with the awesome Serverless framework. It makes setting up serverless applications incredibly easy.
While setting up a serverless application by using a serverless.yml or serverless.ts file, it’s possible to dynamically replace values by using variables. These might be values such as environment variables, table names, or anything else that you might want to be able to change.
Why are feedback loops important
Feedback loops are incredibly important in software development and come in many forms. Each type of feedback loop will take a different amount of time. For example, getting feedback from users is a feedback loop that can potentially be quite large, where as unit tests give feedback much more quickly, resulting in a shorter feedback loop.
By shortening feedback loops as much as possible you can realise value much more quickly.
Here are some great examples of feedback loops from Extreme Programming
Many practices within Extreme Programming are geared towards reducing various feedback loops. For example, code reviews are great, but why not make them even better and get the same feedback from paired programming? Or why wait for your application to run to find out you have a bug when you can get that feedback from running unit tests?
Sls print example
While recently working with variables in Serverless, I was testing to see if my variables were being correctly populated by deploying the stack to AWS. In testing if the variable was working, this was fine, it showed me that they were. But the feedback loop of deploying a full stack to test a variable felt way too long.
I then started testing the variable by using the serverless offline plugin. This reduced the length of the feedback loop by removing the need to deploy the stack to AWS.
However, a colleague then showed me the Serverless print command. This will print out your fully resolved serverless file. So now I had an even shorter feedback loop!
Firstly, I was deploying the stack to test the variable replacement. I was able to reduce the feedback loop by using the serverless offline plugin by being able to test the stack locally. By using the sls print function I was able to reduce the feedback loop even further by printing out the serverless file after variable replacement. All three of these approaches gave the desired feedback around the variable but with shorter lengths.
Any time you can reduce feedback loops, you are more likely to be able to realise value sooner.