Subnet
A Subnet is a synthetic resource — it is never declared directly in user config. The planner auto-injects subnets based on Vpc.distributeAcrossAzs. Each subnet is either public (with Internet Gateway route) or private (NAT-only). Providers create real cloud subnets during Vpc creation.
Config
Section titled “Config”| Property | Type | Required | Description |
|---|---|---|---|
name |
string |
yes | Subnet name (auto-generated by planner) |
vpc |
Vpc | string |
yes | Parent VPC reference |
cidr |
string |
yes | CIDR block within the VPC |
az |
string |
no | Availability zone override |
public |
boolean |
yes | Whether this subnet has a route to the internet |
While Subnet can be constructed directly in code, the recommended approach is to rely on auto-injection via Vpc.distributeAcrossAzs.
Example
Section titled “Example”import { Vpc } from '@kykucloud/types'
const myVpc = new Vpc({ name: 'my-vpc', cidr: '10.0.0.0/16', region: 'eu-central', distributeAcrossAzs: 3, // creates 3 public + 3 private subnets})Provider Support
Section titled “Provider Support”| Provider | Supported | Backend |
|---|---|---|
| AWS | ✅ | EC2-VPC subnet (public + private per AZ) |
| GCP | ✅ | Synthetic (auto-injected by planner; no GCP subresource) |
| Hetzner | ✅ | Synthetic (auto-injected by planner; subnets created as part of Network) |
| DigitalOcean | ✅ | Synthetic (auto-injected by planner; subresources within VPC) |
- Synthetic resource: Subnet has no standalone cloud lifecycle. The parent
Vpcmanager handles creation and destruction. - AWS:
distributeAcrossAzscreates paired public/private subnets per AZ. The AWS provider always creates this topology. - Hetzner: Servers need a subnet before attaching to a network. Always create subnets via
distributeAcrossAzs >= 1. - GCP & DO: Subnet is an auto-injected abstraction.
createResource/destroyResourceare no-ops; VpcManager handles everything.