Encore.go
An open source infrastructure SDK for Go
Encore.go is an open source infrastructure SDK that lets you declare the cloud infrastructure your application needs, such as databases, Pub/Sub topics, object storage, caches, cron jobs, and secrets, directly in your Go code.
Instead of stitching together Terraform, YAML, and cloud consoles to wire up these resources, you declare them as typed values and use them through their SDK methods. Encore then takes care of running the matching infrastructure locally during development, and (with Encore Cloud) provisioning the real cloud resources in your own AWS or GCP account when you deploy.
What you get with Encore.go
- Infrastructure as Go: Declare SQL databases, Pub/Sub topics and subscriptions, object storage buckets, caches, cron jobs, and secrets as values in your code. Encore understands how these resources are used and generates the runtime wiring for you.
- Local infrastructure, automatically: Run
encore runand Encore boots a local environment that mirrors production: real Postgres, a local Pub/Sub broker, local object storage, and so on. No Docker Compose files to maintain. - Type-safe service-to-service calls: Define APIs as plain Go functions. Calling another service is a normal function call; Encore handles serialization, routing, and validation at the boundary.
- Built-in observability: A local development dashboard with distributed tracing, logs, and a database explorer, so you can see what your application is doing without bolting on extra tools.
- AI-ready by design: Because infrastructure is declared in code, AI coding assistants can understand and modify your full stack. Encore also ships AI instructions and an MCP server for editor integrations.
The infrastructure primitives
Each primitive is a package-level variable you declare in the same file as the code that uses it. Together they cover the infrastructure most backend applications run on. Anything outside the set connects as an external dependency.
import "encore.dev/storage/sqldb"
var db = sqldb.NewDatabase("orders", sqldb.DatabaseConfig{
Migrations: "./migrations",
})
Declarations describe the infrastructure the application needs, and services and APIs are declared the same way. Provisioning settings are configured separately. Encore reads all of it into the application model, which drives provisioning, IAM and code generation.
Declarations are environment-independent, so the same application code runs in local, preview, and production environments without environment-specific checks. See Development workflow for the process from encore run through per-PR preview environments and production.
Local and cloud implementations
encore run starts a local implementation of each one, and in cloud environments Encore Cloud provisions the managed equivalent in your own AWS or GCP account. You can also provision the infrastructure yourself and point Encore at it with an infra config file.
| Primitive | Locally | AWS | GCP |
|---|---|---|---|
| SQL Database | Postgres in Docker | RDS | Cloud SQL |
| Pub/Sub | in-memory | SNS + SQS | Cloud Pub/Sub |
| Object Storage | local filesystem | S3 | Cloud Storage |
| Caching | in-memory Redis | ElastiCache | Memorystore |
| Cron Jobs | not triggered | Encore Cloud Managed | Encore Cloud Managed |
| Secrets | set per environment | Secrets Manager | Secret Manager |
Cron jobs are not triggered automatically in local or preview environments. You can invoke their endpoints from the development dashboard.
Compute is chosen per environment rather than declared in code: Cloud Run or GKE on GCP, Fargate or EKS on AWS. Infrastructure on AWS and GCP also covers networking.
Services and APIs
Services and APIs are included in the application model, where Encore validates their definitions and relationships.
- App Structure: how an application is laid out, and how services fit together in a monorepo.
- Services: group related APIs and infrastructure into independently deployable services.
- Defining APIs: expose typed endpoints from a service. Encore handles request validation, routing and client generation.
- API Calls: call another service's API as a regular typed function, wired up in-process locally and over the network in production.
Request and response data
- Validation: incoming requests are checked against the declared schema before your handler runs.
- API Errors: return structured errors with codes that map to HTTP statuses.
Other API styles
- Raw Endpoints: access the underlying request and response objects.
- Service Structs: define APIs as methods on a struct, with dependencies initialized once per service.
From local to production
Because the SDK is the source of truth for your infrastructure, the same model runs locally, in per-PR preview environments, and in production. encore run boots the whole system on your laptop with real Postgres, real Pub/Sub semantics, and real tracing. Opening a pull request spins up a preview environment with the same infrastructure model and (optionally) a database branched from a seed environment.
This is the loop that makes Encore.go particularly effective with AI coding agents: every change can be validated end-to-end against real infrastructure, locally and in the cloud, instead of waiting for a production deploy to find out if it works. For more, see the Development Workflow page.
Encore.go is fully open source and you are never locked into a particular deployment path. There are two supported ways to run an Encore.go application in production.
With Encore Cloud: the optional managed platform reads the infrastructure you declared in your code and provisions matching resources (RDS, Cloud SQL, SNS+SQS, Pub/Sub, S3, GCS, etc.) in your own AWS or GCP account, then manages deploys, environments, secrets, and IAM on top. You own the cloud account and the infrastructure; Encore Cloud is the control plane that drives it from your code.
Self-hosted: build a standard Docker image with encore build docker and run it anywhere. You provision your own infrastructure however you like (Terraform, Pulumi, CloudFormation, the cloud console), and tell the Encore runtime how to reach those resources via an infrastructure config file. See the self-hosting guide for the full workflow.
Primitives and AI agents
Primitives expose infrastructure resources as typed objects. Deployment-specific settings are configured per environment. This separation helps agents produce valid declarations, with invalid usage reported by the type system or at build time.
For example, an agent can declare a database with only a name and a migrations directory:
var db = sqldb.NewDatabase("orders", sqldb.DatabaseConfig{
Migrations: "./migrations",
})
An equivalent Terraform configuration may also define the database instance class, storage type, networking, parameter group, and IAM policy. Encore handles these concerns as follows:
- Deployment settings such as instance size, networking, and backups are configured per environment and remain outside the application code.
- Resource names must be string literals, and resource declarations must be defined at package scope. Invalid declarations are reported at build time. See Understanding Encore for the complete requirements.
- IAM policies are derived from resource usage, limiting permissions to the relationships declared in the application.
- Request schemas are derived from Go types, so invalid client usage and handler signatures produce compile-time errors.
See AI integration for editor rules and an MCP server that expose the service graph, schemas, and traces to agents. Coming from Terraform maps Terraform concepts to Encore and covers using both together.
Other infrastructure
Primitives do not limit the infrastructure your application can use. For services without a primitive, such as a search cluster or data warehouse, provision them separately, connect to them as external dependencies, and store their connection details in secrets.
Resources you already run can be connected to a declaration rather than provisioned new. Encore imports existing databases, buckets, and topics on AWS and GCP, and deploys into an existing Kubernetes cluster.
To see exactly what Encore creates in your cloud, see Infrastructure on AWS and GCP.
Where to go next
- New to Encore? Start with the Quick Start to build and run your first application.
- Want to understand the model first? Read App Structure and the Services page.
- Curious about the local-to-production iteration loop? See the Development Workflow.
- Ready to deploy? See Deploy with Encore Cloud or Build Docker Images for self-hosting.
Get started
Paste into your coding agent to install Encore and scaffold an app.
Paste into your coding agent to install Encore and scaffold an app.