How do we set up a proper serverless development workflow?
If you’ve built a serverless application or two, you’re probably familiar with the benefits of serverless architecture. You take advantage of already built, managed cloud services to handle standard application requirements like authentication, storage, compute, API gateways, and a long list of other infrastructure needs. You can spin up these resources in a matter of minutes and add your own specific business logic (usually as AWS Lambda function code). You can deploy highly reliable cloud applications that scale well, have low operational overhead, and are (usually) very cost efficient. You don’t need to divert resources into developing and managing your own infrastructure platform.
There’s another side to the serverless story: developer workflow
Understanding the benefits of serverless is easy, but building serverless apps well requires effective development workflows. If you’re moving beyond “running one or two Lambdas” you will want to be thinking about patterns and process for serverless development.
There are three things developers need from their development environment:
- A short iteration cycle for making code changes and executing them. This minimizes context switching and enables developers to quickly develop and debug code.
- The ability to iterate on the application’s infrastructure and keep configurations consistent across environments.
- A high level of consistency with the production environment. This helps ensure functionality that works in development will also work when deployed.
Figuring out serverless development workflows can feel befuddling
There are three key areas where serverless impacts developer workflow.
- Infrastructure (Configuring Managed Cloud Services)
- Business Logic (Application Code, AWS Lambda, Fargate, etc.)
- Build & Deploy Pipeline (deployment process from source code to production)
Let’s look at what engineering teams need in each area to build effective workflows
1. Infrastructure (Configuring Managed Cloud Services)
If you’ve ever counted how many words are in all of AWS’ online documentation, you’ll know that the answer is about 15.2 million words. If you devoted 40 hours a week to reading them, it would take you a full year or two. Of course, most people will never read these reference docs cover to cover, but it points to the sheer magnitude of the choices engineers face when configuring their serverless infrastructure.
If you can learn to leverage this vast body of information, you can quickly spin up services for job queueing, GraphQL, PubSub, ML, AI, DBs, you name it and knit them into your own applications. However, this is a huge shift for most engineers from programming on a traditional LAMP style architecture. It is easy to get stuck switching between a ton of different tools and browser tabs when developing serverless projects, slowing things down and possibly leading to errors and inconsistencies as the project’s complexity grows.
A key ingredient to succeeding with serverless is ensuring you have clear patterns in place for defining your infrastructure as code (e.g. AWS SAM) and managing it across a set of cloudside environments. You’ll also want to have clear patterns and tooling for configuring and integrating the cloud services you’ll need to build effective development environments— and to minimize time spent writing boilerplate YAML configs.
Solving the infrastructure configuration challenge
Stackery’s Visual Infrastructure Editor is now available as a VSCode Extension. It allows developers to quickly get up to speed in regards to defining and configuring cloud infrastructure services. You can read more in the docs.
2. Business Logic (Application Code, AWS Lambda, Fargate, etc.)
This area is arguably the most important from a workflow perspective. This is where you want to be putting most of your effort— into the unique problems your application solves. The biggest challenge serverless introduces is that cloud managed services generally can’t be run locally, so local development gets a lot more challenging. There are several common approaches to doing local development for serverless application code. The cloudlocal approach involves provisioning a cloudside version of your architecture in a development AWS account and then executing code locally in an identical configuration to how it runs cloudside.
Solving the serverless local development challenge
I’ve written quite a bit about this recently in How to Serverless Locally so I won’t go into more detail here, but encourage you to read that post on developing functions against live cloud resources. Our new VS Code plug-in is exciting here because you can now develop application code and cloud resources in a single tool. Finally, for non-VS Code IDEs, you can use the
stackery edit CLI command to set up editing local template files in your browser.
3. Build & Deploy Pipeline (deployment process from source code to production)
The final key area of consideration when planning your serverless workflows is how you will get changes you make in development into test and eventually production environments. The process for deploying serverless applications looks quite a bit different than deploying to server-based architectures.
For example, the steps to deploy an AWS SAM application look roughly like this:
- Install and compile your Lambda function dependencies
- Create Lambda code package zip files
- Upload the zip files to s3 in the correct AWS account and region
- Generate a deployable Cloudformation template which references uploaded zip files
- Submit the generated template to CloudFormation
- Execute the CloudFormation Change Set
While none of these steps involve rocket science, it’s important that you have a good automated process that manages code through these rote steps for each of the environments you deploy to.
Solving the serverless deployment challenge
There are a few key things you’ll want to look for when setting up a serverless deployment workflow:
- Is it reliable and automated?
- Are builds always run in a consistent environment?
- How do you customize builds on a per-app basis? It’s common to need custom build steps for specific applications and these should be easy to add.
- How do you debug build issues? While you generally will want to run your deployment process from with cloudside CI/CD system it is very useful to be able to run the process locally to debug issues with function building, compilations, etc.
There is more information about how Stackery handles the serverless deployments in our technical documentation.
The serverless workflow prescription
One of the best things about my job is that I get to interact with a lot of developers building serverless applications who are using Stackery. I get to learn about the problems they’re solving at their companies with serverless apps— and frequently they’re looking for information on a certain best practice or how to remove a pain point from their workflow.
There’s a huge win ahead for the serverless community as we solve the current developer workflow challenges and unlock the benefits of a serverless approach to more and more developers. At Stackery, we’re working toward this and have rolled out a set serverless development workflow tools (which can be used with a free developer account). If you’re looking at how to improve your infrastructure workflow, check out the Stackery Visual Editor and VSCode Extension. For business logic and local development workflow, refer to the
stackery local CLI commands. For build & deploy, you can read about how Stackery models serverless deployments and provides configurable strategies in our docs.
The best practices around serverless development workflows are becoming increasingly clear to the engineers who have pioneered serverless techniques. Once serverless developers “on the ground” learn and adopt them, they’ll benefit from more focused building, accelerated production, and a better quality of life.
Want to see these workflow-bettering practices in action? Join us for one of our upcoming serverless development livestreams every Wednesdays at 10 AM PDT. Between our stellar serverless team-members and occasional guest-hosts, we’ll tackle your toughest development challenges/questions and show you Stackery in action! Register for the livestream.