AWS Open-Sources \"Blocks\" - A TypeScript Framework to Compose Cloud-Native Backends
By Vatsal Shah | June 26, 2026 | 7 min read | Source: AWS Developer Blog
AI SUMMARY
- Direct Cloud Compilation:
- AWS Blocks compiles TypeScript code directly to native serverless resource stacks, bypassing intermediate IaC (Infrastructure as Code) templates.
- Syntactic Simplicity:
- Replaces verbose CDK setups with inline decorators, mapping standard code functions to Lambda routes and database instances in a few lines.
- Serverless-First Runtime:
- The framework abstracts physical server layout and network gateways, compiling standard JavaScript APIs directly to AWS cloud endpoints.
Lead Paragraph
SEATTLE, Washington — In a move designed to simplify serverless software engineering, Amazon Web Services (AWS) has open-sourced the developer preview of Blocks, a TypeScript framework hosted on the awslabs GitHub repository. Rather than separating infrastructure configuration from business logic, Blocks introduces an integrated programming model. Developers declare backend logic in standard TypeScript, and the compiler automatically outputs native cloud resource templates (AWS Lambda, DynamoDB, API Gateway). Bypassing verbose manual AWS Cloud Development Kit (CDK) constructs, Blocks directly targets developer experience challenges, positioning itself against popular orchestration platforms like SST and Pulumi.
What Happened
The launch of the open-source Blocks project introduces a compiler-driven approach to provisioning cloud infrastructure. Instead of writing separate YAML configuration templates or executing complex CDK deploy files, developers use standard TypeScript decorators. Key capabilities in the preview include:
- Inline Architecture Composition: Functions and classes are mapped directly to microservices using decorators (e.g.,
@HttpEndpointor@Table). - Compile-Time Verification: The compiler validates permissions, IAM policies, and VPC routing targets before building resources.
- Direct Cloud Compilation: Bypasses intermediate IaC compilation phases, translating TypeScript structures into AWS CloudFormation and direct API deployments in seconds.
AWS BLOCKS COMPILATION FLOW
+--------------------------------------------------------------------------+
| TypeScript Code (with @Blocks decorators) |
| │ |
| ▼ (Blocks Compiler - Compile-Time Verification) |
| [ AWS Identity & Route Checks ] ──► [ Direct Resource Mapping ] |
| │ |
| ▼ (Cloud Native Resource Generation) |
| AWS Cloud Infrastructure (Lambda, DynamoDB, API Gateway) |
+--------------------------------------------------------------------------+Why It Matters
For mobile backend developers, serverless engineers, and engineering leaders, AWS Blocks addresses a long-standing developer experience bottleneck. Traditionally, building a serverless API required maintaining two distinct codebases: the infrastructure configuration (CDK, Terraform, or Serverless Framework) and the application code itself. This separation caused "configuration drift," where security policies and database tables fell out of sync with application updates.
By integrating infrastructure composition directly within application code, Blocks eliminates configuration drift. If a developer adds a database parameter to a query block, the framework automatically updates the DynamoDB table schema and configures the necessary IAM execution permissions. This reduces development overhead, simplifies onboarding for frontend developers transitioning to cloud-native backends, and decreases build-phase debugging cycles.
H2: The Blocks Compilation Architecture
The core innovation of the Blocks framework is its specialized compiler. The tool parses TypeScript abstract syntax trees (ASTs) to identify custom @HttpEndpoint, @Queue, and @Table metadata tags.
During the compilation process, the framework performs static analysis to verify network isolation, database index keys, and API schema targets. For example, if a handler attempts to write to a DynamoDB table without proper keys, the Blocks compiler throws an error during local validation, preventing a failed deploy cycle on AWS. Once verified, the compiler generates optimized JS bundles for Lambda runtimes and provisions the supporting network routing gateways.
H2: Blocks vs CDK
To illustrate the reduction in boilerplate code, the comparison below highlights the syntactic difference between configuring a serverless route in the AWS CDK versus composing it with the new Blocks framework.
In AWS CDK, composing a basic REST API endpoint with a DynamoDB table requires defining a Stack class, configuring the DynamoDB Table construct, initializing the Lambda Function construct, granting read/write permissions, and registering the route in API Gateway. AWS Blocks collapses these definitions into inline code blocks.
Developers can compose this architecture in a single TypeScript file using the Blocks runtime:
import { HttpEndpoint, Table, Query, Mutation, BlockApp } from "@aws-labs/blocks";
// Compose a DynamoDB database table using the @Table decorator
@Table({
tableName: "UserRegistry",
partitionKey: "userId",
billingMode: "PAY_PER_REQUEST"
})
export class UserTable {
public userId!: string;
public email!: string;
public registeredAt!: string;
}
// Compose the application backend API using the @BlockApp container
@BlockApp({
appName: "UserRegistrationService",
region: "us-east-1"
})
export class UserRegistrationBackend {
private users = new UserTable();
// Composes a secure HTTP POST endpoint mapping to AWS API Gateway and Lambda
@HttpEndpoint({
method: "POST",
path: "/users/register",
description: "Registers a new user and stores metadata in DynamoDB"
})
@Mutation()
public async registerUser(email: string): Promise<{ success: boolean; userId: string }> {
const newUserId = `usr_${Math.random().toString(36).substr(2, 9)}`;
const timestamp = new Date().toISOString();
// The compiler automatically configures IAM write permissions for this call
await this.users.put({
userId: newUserId,
email: email,
registeredAt: timestamp
});
return {
success: true,
userId: newUserId
};
}
// Composes an HTTP GET route to fetch user data
@HttpEndpoint({
method: "GET",
path: "/users/{userId}",
description: "Fetches user metadata from the DynamoDB registry"
})
@Query()
public async getUser(userId: string): Promise<UserTable | null> {
// The compiler automatically configures IAM read permissions for this query
return await this.users.get({ userId });
}
}What to Watch Next
- CDK Interoperability Support: Look for updates that allow developers to import existing CDK constructs directly into Blocks classes to support complex legacy architectures.
- Local Simulation Tooling: Watch for the release of offline sandbox simulation tools to speed up local testing cycles before deploying resources to AWS.
- Third-Party Engine Extensions: Monitor if the open-source community contributes plugins to compile Blocks syntax to other cloud providers, challenging Pulumi’s cross-cloud strategy.
Read the official repository documentation on GitHub labs → AWS Blocks Repository
Key Takeaways
- CDK Boilerplate Bypassed: AWS Blocks combines application code and infrastructure configuration into a single programming model.
- TypeScript Decorator Syntax: Decouples configuration templates by mapping endpoints and databases using inline class decorators.
- Automated Security Models: The compiler evaluates route mappings to auto-generate IAM execution policies and access controls.
- Pre-Deployment Testing: Built-in static analysis verifies database keys and network targets before building CloudFormation stacks.
- Direct Serverless Deployment: Translates TS functions directly into Lambda deployments and API Gateway routing structures.