Unlocking the Power of Infrastructure “from” Code with Encore: A Developer-Friendly Solution
Tags: distributedsystems, microservices, go
Published: 2023-04-20 08:14:10

---
title: Unlocking the Power of Infrastructure “from” Code with Encore: A Developer-Friendly Solution
published: true
description: 
tags: distributedsystems, microservices, go

# cover_image: 
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-10 08:34 +0000
---
## Infrastructure as Code & Serverless Computing.

Infrastructure as Code (IaC) has been making waves in the software development industry for many years now. In essence, IaC is the process of managing and provisioning infrastructure (think servers, storage, networking, and the like) through code rather than manual configuration. With this approach, developers can control their infrastructure using the same version control system they use for their code, making it simpler to collaborate, test, and deploy infrastructure changes.

Nonetheless, as the trend towards serverless computing takes hold, many developers are turning their attention away from managing infrastructure and towards coding. Serverless computing enables developers to create and operate applications without the burden of infrastructure management. This approach has numerous advantages, including quicker time-to-market, less operational overhead, and automatic scaling.

However, there's a catch. When you start with a serverless stack, it can be tough to switch to a different provider or hosting model. The APIs that interact with the serverless infrastructure are embedded with your code, making it a challenge to migrate to another provider, even if it promises cost savings or superior features.

## The Future of Provisioning: Infrastructure From Code

What if you could concentrate on coding and let the infrastructure take care of itself? What if infrastructure could comprehend your code and provision itself? This is the future of provisioning, and it's already in motion.

Recently, I stumbled upon Encore. Encore simplifies backend development by stating infrastructure using annotations and the framework used in your backend application or microservices. You can bypass writing tons of Terraform, boilerplate, and configuration. It's almost like magic!

```go
import (
    "context"
)

// This is a REST API that responds with a personalized greeting.
//
//encore:api public path=/hello/:name
func World(ctx context.Context, name string) (*Response, error) {
    msg := "Hello, " + name + "!"
    return &Response{Message: msg}, nil
}

type Response struct {
    Message string
}

```

This *example is a REST API written in golang that responds with a personalized greeting. We use the **`encore:api`** directive/annotation to tell Encore that this function should be exposed as an API, and we specify the route that should be used to access it.*

## Benefits of using Encore.

Encore's approach is founded on the principle of understanding your codebase. This makes the development of microservices super smooth, with all the perks of building monolithic applications. It's simple to run locally and on your cloud infrastructure, and the team even provides a free development environment. This demonstrates how much they care about the impact their product can have on startups and how it can help them grow rapidly.

Everything that makes Encore so cool is open sourced, so if you ever decide not to continue with the tool, you can still run your app. And if you want to migrate away, it's simple because most of the code you write is Golang. This is brilliant because when you boast about preventing vendor lock-in, it's only proper to ensure you're not becoming what you're preventing.

All of this is feasible because Encore can comprehend your codebase. It employs static analysis to understand your application, allowing you to write portable code that can be run on a variety of different infrastructure providers. This means you can develop your backend application with Encore and then deploy it to the cloud provider of your choice, whether it's AWS, GCP, or Azure. Encore handles the provisioning and management of your infrastructure resources, allowing you to focus on creating your application and delivering value to your users.

To me, this approach feels more fitting. When you have an in-depth understanding of the code, anything becomes possible. With access to all the variables including how the code uses the resources, Encore can make more informed decisions about the infrastructure. This approach prioritizes the developer experience over asking them to learn how to provision, reducing the time and effort required for deployment.

Encore's ability to understand your code and provision to your preferred cloud provider makes it easier to migrate to another provider if necessary. Additionally, the ability to only provision the necessary resources results in a more cost-effective solution, optimizing infrastructure usage and reducing unnecessary expenses.

One limitation of Encore is that it currently only supports Golang api/apps. However, during a call with the founder Andrè, he mentioned that they are looking to support other languages in the future.

Encore offers several business advantages, including quicker time-to-market, reduced operational overhead, and cost savings.

## **Next in the Horizon**

Infrastructure From Code is the next step in the evolution of infrastructure management, as it empowers developers to provision and manage infrastructure resources themselves while coding. This approach allows for more efficient collaboration between developers and operations teams and accelerates the development process.

Encore is leading the way in this approach, using static analysis to comprehend your codebase and provision the required resources automatically. This not only allows developers to focus on writing code, but also promotes collaboration between teams, resulting in faster delivery times, decreased operational expenses, and cost savings.

As technology advances, it is crucial that we stay ahead of the curve and adopt innovative approaches like Infrastructure From Code to stay competitive. Encore is a fantastic example of this, and I am excited to see what the future holds for this revolutionary technology.

To learn more about Encore, explore their [documentation](https://bit.ly/encoredoc) or engage with their growing community **[here.](https://bit.ly/encoreslack)**