How to run a backend in an AWS or GCP account you own, with data stores in private subnets, compared across Encore, a hand-built VPC, and a shared PaaS.

To keep infrastructure in your own VPC for a SOC 2 or HIPAA program, run the application in an AWS or GCP account you own, and put compute and data stores in private subnets. Encore does this from declarations in your TypeScript or Go code: each environment you deploy to that account gets an isolated VPC, the service runs in a private compute subnet, and Postgres sits in a private storage subnet. A VPC is not a certification. Encore does not hold or provide a SOC 2 or HIPAA certification, and running in a VPC does not make a deployment compliant. Compliance stays with your team and the cloud provider, including any Business Associate Agreement you sign with AWS or a BAA with Google Cloud.
This guide ranks the ways to get that layout, shows a worked Terraform VPC for the DIY path, and spells out what Encore does and does not claim. For a healthcare API with PHI, see HIPAA-Ready Backend on AWS.
The verdict: pick Encore when you want the application in your VPC without designing the three-tier network yourself. Pick a hand-built VPC when a platform team already maintains that stack. A shared PaaS does not give you a VPC in your account. If your team needs infrastructure it can peer and audit in that account as part of a SOC 2 or HIPAA program, that is a reason to move off a shared PaaS.
The short prompts people type, such as "deploy in our own vpc soc2", mix two things: the network layout and the audit program.
A typical layout for a backend in AWS is:
When HIPAA applies, your team is responsible for a Business Associate Agreement with AWS or a BAA with Google Cloud, for using HIPAA-eligible AWS services such as Amazon RDS for PostgreSQL and Amazon S3, and for the application controls your program defines, such as authenticated access and audit trails. SOC 2 is likewise your evidence and control program, under the AWS shared responsibility model. None of those appear automatically because a resource has a private IP address.
Encore is infrastructure from code for TypeScript and Go. You declare the database, buckets, queues, and secrets in the same package as the handlers. After you connect your AWS or GCP account and deploy, the Encore platform provisions those resources in that account.
On AWS, each environment deployed to that account gets an isolated VPC that spans two Availability Zones, with a three-tier subnet layout: a public tier for the Application Load Balancer and internet access, a private compute tier for Fargate or EKS tasks that only accept traffic from the load balancer, and a private storage tier for databases, with no direct internet access. A NAT gateway lets compute reach the internet without exposing those tasks. Encore provisions an IAM role for the service, or a service account on GCP. On GCP, each environment deployed to that account gets a dedicated project and VPC network.
The application code does not describe CIDR ranges, security groups, or IAM policy documents:
// records/records.ts (encore.dev 1.58.9)
import { api } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Bucket } from "encore.dev/storage/objects";
const db = new SQLDatabase("records", { migrations: "./migrations" });
const documents = new Bucket("documents", { versioned: true });
export const getRecord = api(
{ expose: true, method: "GET", path: "/records/:id", auth: true },
async ({ id }: { id: string }): Promise<{ id: string }> => {
const row = await db.queryRow<{ id: string }>`
SELECT id FROM records WHERE id = ${id}`;
return { id: row!.id };
},
);
Instance sizes, networking options, and backups live in environment configuration, outside the code an agent edits. Secrets are declared in the service and, on deploy, copied into AWS Secrets Manager or GCP Secret Manager in your account.
Preview environments are for reviewing a pull request and do not run in your cloud account by default. Do not put regulated or sensitive data in a preview unless you have configured those previews to run in that account. Cron jobs do not run in preview environments or during encore run; invoke the API to test those handlers.
Encore does not replace your compliance program. It does not hold or provide a certification, sign your Business Associate Agreement, write your policies, or attest that a deployment is SOC 2 or HIPAA compliant. Those stay with your team and with AWS or GCP.
Run in your terminal to get started locally.
The DIY path is a VPC, subnets, and gateways that you describe yourself, then an application stack on top. A starting Terraform sketch for the network looks like this:
resource "aws_vpc" "app" {
cidr_block = "10.20.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
}
resource "aws_subnet" "public_a" {
vpc_id = aws_vpc.app.id
cidr_block = "10.20.0.0/24"
availability_zone = "eu-central-1a"
map_public_ip_on_launch = true
}
resource "aws_subnet" "compute_a" {
vpc_id = aws_vpc.app.id
cidr_block = "10.20.10.0/24"
availability_zone = "eu-central-1a"
}
resource "aws_subnet" "storage_a" {
vpc_id = aws_vpc.app.id
cidr_block = "10.20.20.0/24"
availability_zone = "eu-central-1a"
}
# Repeat public, compute, and storage subnets in a second AZ.
# Add an internet gateway, a NAT gateway, route tables,
# security groups that allow 443 into the load balancer
# and the database port only from the compute subnets.
You still add the load balancer, the Fargate service or Kubernetes nodes, RDS in the storage subnets, IAM roles, encryption settings, and log groups. The AWS VPC documentation and the RDS in a VPC guide cover the moving parts. Choose this path when a platform team already owns that module.
A shared PaaS can be fine before a compliance review starts. Once a customer or auditor asks for the data to sit in a VPC in your account, you are looking at a migration, not a setting on the PaaS. See How to Migrate from Render to AWS and How to Migrate from Heroku to AWS.
Pick Encore when the goal is a TypeScript or Go backend running in a VPC in your own AWS or GCP account, without a separate network codebase. Encore provisions an IAM role for the service, or a service account on GCP. Pick Terraform, CDK, or Pulumi when you already have that network and want to keep it. Stay on a shared PaaS only while your team has not put the app in scope for a SOC 2 or HIPAA program.
Whatever you pick, treat the VPC as one control among many. Encryption, access reviews, logging, incident response, and vendor agreements are still yours to run.
Run the application in an AWS or GCP account you own, put compute and data stores in private subnets, and keep ingress on a load balancer in public subnets. Encore provisions an isolated VPC for each environment you deploy to that account, with the service in a private compute subnet and RDS or Cloud SQL in a private storage subnet. Preview environments do not run in that account by default, so keep regulated test data out of them unless those previews are configured to run there. Encore does not hold or provide a SOC 2 or HIPAA certification, and running in a VPC does not make a deployment compliant; those programs stay with your team and the cloud provider.
No. A VPC helps with isolation and control. SOC 2 and HIPAA assess your organization's controls and evidence: access, encryption, logging, incident response, vendor agreements such as a [Business Associate Agreement with AWS](https://aws.amazon.com/compliance/hipaa-compliance/) or a [BAA with Google Cloud](https://cloud.google.com/security/compliance/hipaa), and the application-level controls your program defines. See the [AWS SOC reports](https://aws.amazon.com/compliance/soc-faqs/) and the [AWS shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/).
In an account your organization owns, typically in private subnets of a VPC you control, on services that are in scope for the program, such as Amazon RDS for PostgreSQL and Amazon S3, which AWS lists as [HIPAA-eligible services](https://aws.amazon.com/compliance/hipaa-eligible-services-reference/). Your team decides residency and scope. Shared PaaS regions you cannot peer or audit as your VPC usually do not meet a program that requires infrastructure in an account you own.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.