Last week I was deploying an app to AWS Lambda using Serverless and I accidentally misspelled a
stage name. This resulted in deploying an entire CloudFormation stack with the wrong name, which wasted time and resources. I immediately realized that I spelled it wrong, so I was able to
undeploy the stack quickly. I fully admit that misspelling the name was my fault, but since Serverless can deploy complex CloudFormation stacks that provision users, databases, SNS topics, etc., it seemed like there should be a better way to avoid this simple mistake.
BTW, if you’re not familiar with Serverless, you should really check it out. It’s quite amazing.
I did my research and looked through the Serverless documentation. No mention of it there. I looked through the Serverless plugins, didn’t see anything there. I searched Google and found several additional Serverless plugins, but nothing that did a simple validation on the name of the
stage you were deploying to. For me, this was a real problem that I needed solving. I have several Serverless projects, many of which create additional resources based on the
stage name. If I made that mistake once, I knew I could make it again.
As I mentioned, Serverless has a number of plugins, plus it has a really great plugins system that lets you easily create your own. I read their documentation, created a sample from the template, and tinkered for a while until it did exactly what I needed it to do. I wrote some of my own documentation, published it to Github, and then published to NPM. After that, I submitted it to Serverless’s plugin directory and it was approved the following day.
Now this exists:
It’s simple, easy to use, and solves my problem. I doubt I’m the only one who has had this issue, so hopefully, others find it useful as well. As for me, I’ve added it to most of my Serverless projects and will add it to others as I work on them. And at the very least, I know I have one customer.
Did you like this post? 👍 Do you want more? 🙌 Follow me on Twitter or check out some of the projects I’m working on. You can sign up for my WEEKLY newsletter too. You'll get links to my new posts (like this one), industry happenings, project updates and much more! 📪