Skip to content
← Back to Blog

Engineering

Tuesday, March 7th 2023

Framework-defined infrastructure

Programmatic framework understanding for automatic infrastructure provisioning

Posted by

Infrastructure as code (IaC) is the industry-standard practice for provisioning infrastructure in a repeatable and reliable way. Framework-defined infrastructure (FdI) is an evolution of IaC, where the deployment environment automatically provisions infrastructure derived from the framework and the applications written in it.

The best way to understand it is that a build-time program parses the source code written to a framework, understands the intent behind the code, and then automatically generates the IaC configuration needed to run the software. This means more predictable, lower cost, and lower risk DevOps through truly serverless—dare we say, infrastructureless—architecture.

In this article, we’ll explain how framework-defined infrastructure fits into modern views of infrastructure definition and automation. We’ll then show examples of how framework-defined infrastructure improves the experience of developing in open-source frameworks.

Contextualizing infrastructure as code (IaC)

In the early days of servers and the Internet we ssh-ed (or worse) into individual machines, running install scripts or even configuring production software using graphical user interfaces to provision infrastructure. As the Web scaled, it quickly became clear that this approach wouldn't scale with it, and together with the DevOps movement, IaC became the best practice for provisioning infrastructure in a repeatable and reliable way.

The code in IaC represents a version-controlled description of the desired state of the infrastructure—which, when executed, will create the described system state. In this scenario, infrastructure can refer to:

  • Network equipment and setups
  • Web and application servers
  • Databases and message queues

What is framework-defined infrastructure?

Framework-defined infrastructure abstracts over cloud primitives such as servers, message queues, and serverless functions, making them mere implementation details of the frameworks' concepts:

  • Providing portability between different target infrastructure providers
  • Eliminating the need to manually configure infrastructure to run an application in production
  • Increasing the time spent writing product code over system management
  • Allowing the unchanged use of the framework's native local development tools
  • Standardizing on pre-reviewed secure services

Frameworks use well-established patterns to provide structure and abstraction to applications, making them easier to write and understand. While the word framework is hard to define, the Hollywood principle, "Don't call us, we call you," probably captures best the inversion of control, where the framework manages the high-level application flow while the developer writes code within the hooks provided by it.

Framework-defined infrastructure takes advantage of both this inversion of control and the predictable structure of framework-based applications to automatically map framework concepts onto the appropriate infrastructure without the need for explicit declaration or configuration of the infrastructure.

Note that this post is giving examples based on Vercel's Platform as a Service offering. The concept, however, can be applied more widely as the basic idea of understanding a framework, and generating IaC configuration for it, can also be used for more traditional infrastructure deployments.

Applying framework-defined infrastructure

We'll now show examples of how frameworks automatically map their concepts onto Vercel's infrastructure. Though we'll be using the popular Next.js framework here for demonstration, Vercel's implementation of framework-defined infrastructure supports a multitude of other frameworks based on the same underlying mechanism.

Flowchart showing the process from user code to automatically inferred infrastructure.