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.
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:
| Platform | create provisions |
|---|---|
| AWS | VPC, public and private subnets, route tables, Internet Gateway, NAT Gateway, security group |
| GCP | VPC network, regional subnet, Cloud Router, Cloud NAT, firewall rule |
| Azure | VNet, public and private subnets, NAT Gateway, public IP, Network Security Group |
| Kubernetes, Machines, Local | Nothing. 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
| Mode | Use for | What Alien does |
|---|---|---|
create | Production. 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-default | Development and tests | Uses 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-aws | An existing AWS VPC | References your VPC, subnets, and security groups. Creates nothing. |
byo-vpc-gcp | An existing GCP VPC | References your network and subnet. Creates nothing. |
byo-vnet-azure | An existing Azure VNet | References 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 3To 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| Flag | Mode | Notes |
|---|---|---|
--network auto|use-default|create|byo | auto (default) creates a Network only when the stack needs one. | |
--network-cidr, --availability-zones | create | The CIDR is chosen for you when omitted. Zones default to 2. |
--vpc-id, --public-subnet-ids, --private-subnet-ids, --security-group-ids | byo on AWS | Lists are comma-separated. Security groups are optional. |
--network-name, --subnet-name, --network-region | byo on GCP | |
--vnet-resource-id, --public-subnet-name, --private-subnet-name | byo on Azure | |
--endpoint-access internet|private | any | Who 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:
{
"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.jsonSee Settings reference for every field.
Outputs
| Field | Notes |
|---|---|
networkId | Cloud network id, such as the VPC id or VNet name |
availabilityZones | Number of zones |
hasPublicSubnets | Whether public subnets exist |
hasNatGateway | Whether a managed NAT gateway exists |
egressPublicIps | Public addresses of the deployment's NAT. Empty when unknown, including BYO networks. Give these to services that allowlist by IP. |
cidr | CIDR block, when Alien created the network |
Permissions
| Set | Grants |
|---|---|
network/provision | Creating the network at initial setup. |
network/heartbeat | Health checks. |