Skip to main content

Introduction

Fjall simplifies AWS infrastructure deployment through factory patterns - high-level abstractions that handle the complexity of creating, configuring, and connecting cloud resources. Instead of managing hundreds of configuration options, factories provide sensible defaults while allowing customization when needed.

The Three Core Factories

Fjall’s infrastructure-as-code approach centers around three main abstractions:

1. Compute Factory

The ComputeFactory deploys application workloads across three compute models:
  • ECS - Container-based deployment with Fargate (serverless), Free Tier (t3.micro), or Spot instances (70% cost savings)
  • EC2 - Traditional virtual machines with auto-scaling groups
  • Lambda - Serverless functions with optional EventBridge scheduling
Learn more about Compute Factory →

2. Database Factory

The DatabaseFactory provisions managed databases:
  • Aurora - Serverless Aurora v2 with auto-scaling capacity and built-in RDS Proxy
  • Instance - Traditional RDS instances with configurable size and Multi-AZ support
  • FreeTier - Cost-free development databases (t3.micro, single-AZ)
Learn more about Database Factory →

3. Network Configuration

Network configuration is passed during App initialization and controls VPC setup:
  • Maximum availability zones
  • NAT gateway configuration (cost optimization)
  • VPC flow logs
  • Interface and gateway VPC endpoints
Learn more about Network Configuration →

How Factories Work

All factories follow a consistent pattern:
import { App, ComputeFactory, DatabaseFactory } from "@fjall/components-infrastructure";

// Initialize app with network config
const app = App.getApp("MyApp", {
  network: {
    maxAzs: 2,
    natGateways: false,
  }
});

// Build factory configuration
const database = app.addDatabase(
  DatabaseFactory.build("AppDb", {
    type: "FreeTier",
    databaseName: "myapp",
  })
);

// Deploy compute with automatic connection
app.addCompute(
  ComputeFactory.build("AppApi", {
    type: "ecs",
    ecsType: "fargate",
    containerPort: 3000,
    containerSecretsImport: {
      DATABASE_PASSWORD: database.getCredentials().getImport("password"),
    },
    connections: [database],  // Auto security group rules
  })
);

Key Benefits

Type-Based Routing

A single factory method creates different resources based on the type parameter - no need to learn separate constructors for each AWS service.

Automatic Integration

Factories understand each other. Pass a database to the connections array and security groups are configured automatically. Use helper methods like getCredentials() for type-safe secret imports.

Sensible Defaults

Every factory ships with production-ready defaults: encryption at rest, Container Insights, ECS Exec, proper IAM roles, and CloudWatch logging.

Cost Optimization Built-In

Free Tier and Spot compute options, optional NAT gateways, and right-sized instances make it easy to optimize costs without sacrificing functionality.

App Context

Access defaults from the App context: getDefaultVpc(), getDefaultContainerRegistry(), and more. No need to manually wire every resource.

Next Steps