Docs

Network

A Network is the VPC or VNet a deployment's containers, databases, and sandboxes run in, with its subnets, NAT, routing, and firewall rules. You don't declare it: Alien adds it when the stack needs one, and each deployment picks how it's built, so one stack fits every customer's network.

alien.ts
import * as alien from "@alienplatform/core"

// A Container and a Postgres need a network, so Alien adds one.
const db = new alien.Postgres("db").build()

const api = new alien.Container("api")
  .code({ type: "image", image: "ghcr.io/acme/api:1.4.0" })
  .cpu(1)
  .memory("1Gi")
  .port(8080)
  .link(db)
  .permissions("execution")
  .build()

export default new alien.Stack("acme")
  .add(db, "frozen")
  .add(api, "live")
  .build()

Platforms

With the default create mode, the stack above gets an isolated network in the customer's cloud:

Platformcreate provisions
AWSVPC, public and private subnets, route tables, Internet Gateway, NAT Gateway, security group
GCPVPC network, regional subnet, Cloud Router, Cloud NAT, firewall rule
AzureVNet, public and private subnets, NAT Gateway, public IP, Network Security Group
Kubernetes, Machines, LocalNothing. The cluster or host network is used.

Deployment status shows it as Network, under Networking and access.

When it's added

Alien adds a frozen Network named default-network on AWS, GCP, and Azure when network settings are given, or when the stack has any of these:

  • A Container, Daemon, or ComputeCluster
  • A Postgres
  • A Redis
  • A Sandbox with egress other than { mode: "allow" }

Workers alone don't need a Network.

On Kubernetes, Machines, and Local, the cluster or host network is used and no Network is created. The exception is Kubernetes on a cloud that needs one, such as a stack with Postgres or Redis, or an Alien-managed cluster.

Because the Network is frozen, the customer's admin creates it once during initial setup. Ongoing management doesn't change it.

Modes

ModeUse forWhat Alien does
createProduction. The default when a Network is needed.Creates an isolated VPC or VNet with public and private subnets, NAT, routing, and firewall rules. Instances get private IPs only and reach the internet through NAT. Deletes it all with the deployment.
use-defaultDevelopment and testsUses the AWS default VPC or the GCP default network. Instances get public IPs and no NAT is created. Azure has no default VNet, so Alien creates one with a NAT Gateway.
byo-vpc-awsAn existing AWS VPCReferences your VPC, subnets, and security groups. Creates nothing.
byo-vpc-gcpAn existing GCP VPCReferences your network and subnet. Creates nothing.
byo-vnet-azureAn existing Azure VNetReferences your VNet and subnets. Creates nothing.

In the BYO modes, the customer owns routing and egress: NAT, proxies, VPNs, and firewall rules. Alien validates the references and assigns no public IPs.

The mode can't change after the Network is created. Moving to another mode means a new deployment.

Set it with the CLI

alien deploy and alien deployments create take network flags.

To create a new network with a chosen address range:

alien deployments create --name customer-1 --project acme --deployment-group production \
  --platform aws --network create --network-cidr 100.88.0.0/16 --availability-zones 3

To deploy into a VPC the customer already has:

alien deployments create --name customer-2 --project acme --deployment-group production \
  --platform aws --network byo --vpc-id vpc-0123456789abcdef0 \
  --public-subnet-ids subnet-0aaa,subnet-0bbb --private-subnet-ids subnet-0ccc,subnet-0ddd
FlagModeNotes
--network auto|use-default|create|byoauto (default) creates a Network only when the stack needs one.
--network-cidr, --availability-zonescreateThe CIDR is chosen for you when omitted. Zones default to 2.
--vpc-id, --public-subnet-ids, --private-subnet-ids, --security-group-idsbyo on AWSLists are comma-separated. Security groups are optional.
--network-name, --subnet-name, --network-regionbyo on GCP
--vnet-resource-id, --public-subnet-name, --private-subnet-namebyo on Azure
--endpoint-access internet|privateanyWho can reach public endpoints. private is AWS only.

Set it in stack settings

For CloudFormation, Terraform, or Helm output, pass a settings file to alien render:

stack-settings.json
{
  "network": {
    "type": "byo-vpc-aws",
    "vpc_id": "vpc-0123456789abcdef0",
    "public_subnet_ids": ["subnet-0aaa", "subnet-0bbb"],
    "private_subnet_ids": ["subnet-0ccc", "subnet-0ddd"],
    "security_group_ids": ["sg-0123456789abcdef0"]
  }
}
alien render --format terraform --target aws \
  --stack ./alien.ts \
  --stack-settings ./stack-settings.json

See Settings reference for every field.

Outputs

FieldNotes
networkIdCloud network id, such as the VPC id or VNet name
availabilityZonesNumber of zones
hasPublicSubnetsWhether public subnets exist
hasNatGatewayWhether a managed NAT gateway exists
egressPublicIpsPublic addresses of the deployment's NAT. Empty when unknown, including BYO networks. Give these to services that allowlist by IP.
cidrCIDR block, when Alien created the network

Permissions

SetGrants
network/provisionCreating the network at initial setup.
network/heartbeatHealth checks.

Next

On this page