Learn 30 serverless best-practices with sls-mentor
Pierre Chollet
Posted on July 12, 2023
Your serverless app is not perfect (yet)
Are you currently learning serverless, or are you already an expert? Whatever... AWS offers so many services and possible configurations that it is hard to keep track of all the best practices.
With my team, we've been building serverless apps on AWS for several years now. We've learned a lot, and it seemed natural to us to share our knowledge with the community, with you!
Introducing sls-mentor, a free and open-source tool that automatically analyzes your AWS Serverless application and gives you tips to improve it!
sls-mentor will rate your application against 30 best practices, and then assign you a score in each of the following categories:
- š³ Green IT š³
- š” Security š”
- š Speed š
- š° IT Costs š°
- šŖ Stability šŖ
ā¬ļø I post serverless content very regularly, if you want more ā¬ļø
How does sls-mentor work?
Nothing simpler! With your AWS credentials loaded in your CLI, run the following command:
npx sls-mentor@latest --report
If you encounter errors when running the command, try specifying a profile with -p
and a region with -r
That's all!
ā¹ļø We require credentials with AdminReadOnly permissions. sls-mentor basically executes a bunch of list
and describe
API calls against your resources
The sls-mentor analysis
sls-mentor will then analyze your app directly from the cloud, and produce a super nice report like this one:
The report will be generated in your current directory, in a file called .sls-mentor/index.html
Your app is assessed against 5 categories, and we give you 3 tips to quickly improve your score! For each tip, we give you an explanation of the problem, and a way to fix it.
Behind the scenes, sls-mentor is running a set of 30 rules that we've written. Want more details about what went wrong? The CLI will give you for each resource the list of rules that failed, and the reason why.
ā¹ļø If you don't want a report, but just want to see the list of rules that failed, just remove the --report
flag.
What next? We need your help!
- Our reporting feature is quite new, we want to improve it! Things like service-wide stats, better recommendations are on our roadmap.
- sls-mentor lacks security rules related to IAM policies for example. We will add them soon!
- AWS is not only about serverless, if you have some serverful knowledge to share with us, feel free to contribute!
- We've got existing issues waiting for contributors, and we are open to new ideas too! Feel free to join us on GitHub!
Learn more about sls-mentor
See our website for more information, or check out our GitHub repository!
With the team, we already produced some articles featuring sls-mentor rules in depth. Feel free to check them out!
- Rule UseARM, written by Zineb El Bachiri
- Rule LightBundle, written by Eloi Alain
- Rule EnableHTTPSOnS3, written by Vincent Zanetta
- Rule LimitedAmountOfVersions, written by myself
- Rule NoDeprecatedRuntimes, written by myself
- Rule BlockPublicAccess, written by myself
A big thanks to everyone I am working with on this project, especially Juliette, Marek, Quentin and Vincent!
Posted on July 12, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.