Sizes and networks
Sizes and networks are the capacity and network choices for a customer's deployment: how much CPU, memory, and disk it gets, and which VPC it runs in. With your own setup screen (Build it into your product), your product offers them. When the admin sets up from the deployment portal, its Configure step does.
To offer them in your product:
- Declare CPU and memory ranges in
alien.ts. - Map each size to CPU, memory, and disk, and put the choice on the setup link.
- Put the network choice on the same link.
Declare ranges
A container accepts per-deployment sizes only inside ranges you declare in alien.ts. Give cpu and memory a min, max, and default:
import * as alien from "@alienplatform/core"
const worker = new alien.Container("worker")
.code({ type: "image", image: "ghcr.io/acme/docproc-worker:1.8.0" })
.cpu({ min: 1, max: 4, default: 1 })
.memory({ min: "2Gi", max: "8Gi", default: "2Gi" })
.persistentStorage("50Gi")
.replicas(1)
.port(8080)
.build()
export default new alien.Stack("docproc").add(worker, "live").build()Release this with alien release. Setup links and resizes can then choose values inside the ranges. See Compute.
Map sizes to settings
Server. Define your sizes once, keyed by the container ID from alien.ts, and put the chosen one in the link's deploymentSetupConfig.policy.stackSettings.defaults.compute.
POST /v1/deployment-groups/setup-links
import { alien, PROJECT } from "./alien"
// Your product's sizes, mapped to the container ID "worker" in alien.ts.
export const SIZES = {
small: { cpu: 1, memory: "2Gi", volumeSizeGib: 50 },
medium: { cpu: 2, memory: "4Gi", volumeSizeGib: 100 },
large: { cpu: 4, memory: "8Gi", volumeSizeGib: 200 },
} as const
export type Size = keyof typeof SIZES
export async function createSizedSetupLink(org: { id: string; slug: string }, size: Size) {
return alien.setupLinks.create({
project: PROJECT,
externalId: org.id,
name: org.slug,
setupItems: [{ item: "deployment", required: true }],
deploymentSetupConfig: {
policy: {
allowedPlatforms: ["aws"],
stackSettings: {
defaults: {
compute: { containers: { worker: { ...SIZES[size] } } },
network: { type: "create" },
endpointAccess: "internet",
},
},
},
},
})
}Alien picks machines that fit the chosen size. For pools that run several containers, set a machine type and count under compute.pools.
Your own setup screen. A deployment you create with this link's token gets the same defaults, and the setup step Alien returns carries them. See Build your own setup screen.
Show sizes, not raw CPU
Customers know their workload, not your container's resource needs. Raw CPU and memory fields invite settings that don't fit.
- Say what each size includes: "Medium: 2 vCPU, 4 GiB, 100 GiB disk."
- Show cost as an estimate. Alien doesn't return prices. Compute it from the machine and disk sizes: "Approx. $120/month in cloud costs, billed by AWS".
- No number. Show "Estimate unavailable" rather than nothing, so customers don't read it as free.
Choose the network
stackSettings.defaults.network decides where the deployment runs on AWS:
network.type | What initial setup does | CloudFormation NetworkMode |
|---|---|---|
create | Creates a new VPC with public and private subnets. Optional CIDR and availability zone count. | create-new |
use-default | Uses the account's default VPC. | use-default |
byo-vpc-aws | Uses an existing VPC and subnets the customer names. | use-existing |
endpointAccess decides who can reach public endpoints: internet (default) or private (reachable only inside the network). It's fixed at initial setup.
A customer whose callers run inside their own VPC usually wants the existing VPC and a private endpoint. Pass these defaults on the link, in place of the ones above:
// stackSettings.defaults for an existing VPC and a private endpoint.
export const privateNetworkDefaults = {
network: {
type: "byo-vpc-aws",
vpcId: "vpc-0a1b2c3d4e5f67890",
privateSubnetIds: ["subnet-0aaa1111bbbb2222c", "subnet-0ddd3333eeee4444f"],
publicSubnetIds: ["subnet-0123456789abcdef0", "subnet-0fedcba9876543210"],
},
endpointAccess: "private",
} as constThe TypeScript client writes vpcId and sends vpc_id. Over REST, use the snake_case names: vpc_id, private_subnet_ids, public_subnet_ids, and for create, cidr and availability_zones.
- Outbound access. An existing VPC needs outbound internet access from its private subnets (a NAT gateway or equivalent), so the deployment can pull images and reach Alien. Say so next to the VPC picker, before initial setup fails on it.
- Ask where the callers run. A new VPC isolates the deployment but can put it far from the systems that call it. Offer an existing VPC when callers run inside the customer's network.
- Ask once. Endpoint access can't change after initial setup.
See Networking and AWS.
Test it
- Set up at each size in a test account, and check that the deployment's
stackSettings.computeholds the CPU, memory and disk you chose. - Try an existing VPC without NAT and confirm your page shows the initial setup failure and names the admin as the one who fixes it.
Next
- Build your own setup screen: the page these settings plug into
- Resize a deployment: change the size after initial setup