ComputeFactory.build
type parameter you pass.
Interface
Key options
| Prop | Type | Default | Notes |
|---|---|---|---|
type | "ecs" | "ec2" | "lambda" | "ecs" | Compute deployment model |
ecsType | "fargate" | "freetier" | "spot" | "fargate" | ECS mode (Fargate/Free Tier/Spot) |
ecrRepository | Repository | RepositoryImage | Fjall default | Container image source |
containerPort | number | 80 | Exposed port for ECS |
containerEnvironment | Record<string, string> | — | Plain environment variables injected into the running container |
containerSecretsImport | { [key: string]: SecretImport } | — | Map secrets from other constructs (for example a database) into container secrets |
connections | IConnectable[] | — | Other constructs this service should reach (all-TCP) |
handler | string | — | Lambda handler (required for Lambda) |
runtime | Runtime | — | Lambda runtime (required for Lambda) |
scheduleExpression | string | — | EventBridge schedule (e.g., "rate(5 minutes)") |
instanceType | string | "t3.micro" | EC2 instance type |
ECS Container Deployment
Fargate (Serverless)
The default ECS mode - serverless containers:Free Tier
Cost-free development using t3.micro instances:Spot Instances
~70% cost savings using Spot capacity:Lambda Functions
Basic Lambda
Lambda with Scheduled Trigger
Lambda with Function URL
Example – Fargate service (env + secrets)
containerSecretsImport maps each key to a SecretImport. The secret is
surfaced to the container through AWS Secrets Manager, remaining encrypted at
rest and in transit.
Example – Fargate service
Example – EC2 with SSH
Best Practices
- Use App Defaults:
app.getDefaultContainerRegistry()andapp.getDefaultVpc()for simplified configuration - Connection Management: Pass databases to the
connectionsarray for automatic security group rules - Secret Management: Use
containerSecretsImportfor sensitive data instead ofcontainerEnvironment - Cost Optimization: Use Free Tier for development, Spot for fault-tolerant workloads, disable NAT gateways when possible
See Also
- Database Factory - Connect databases to compute resources
- Network Config - Configure VPC and networking