VPC · Networking

Subnet

Manage VPC subnets, availability zones, IP behavior, and tags.

Generic driverUniform lifecycle
Scope
Composite
Spec fields
6
Outputs
10
Lookup
Supported

Resource definition

What this resource looks like

This is the CUE shape a Praxis template uses to declare a Subnet. The resource key is local to the template; metadata.name supplies its stable Praxis identity.

CUE example
resources: app: {
  apiVersion: "praxis.io/alpha"
  kind: "Subnet"
  metadata: {name: "app-a", labels: {}}
  spec: {
    region: "us-west-2"
    vpcId: "${resources.network.outputs.vpcId}"
    cidrBlock: "10.42.10.0/24"
    availabilityZone: "us-west-2a"
    mapPublicIpOnLaunch: false
    tags: tier: "application"
  }
}

Desired state

Configuration

The spec block accepts 6 fields. 5 are required by the schema; fields with defaults can be omitted.

regionRequired

region is the AWS region for the subnet.

string
String
vpcIdRequired

vpcId is the VPC to create the subnet in.

string
String
cidrBlockRequired

cidrBlock is the IPv4 CIDR block for the subnet.

string & =~"^([0-9]{1,3}\\.){3}[0-9]{1,3}/([0-9]|[12][0-9]|3[0-2])$"
Enum
availabilityZoneRequired

availabilityZone is the AZ to create the subnet in.

string
String
mapPublicIpOnLaunchOptional

mapPublicIpOnLaunch controls whether instances launched in this subnet receive a public IPv4 address by default.

bool | *false
BooleanDefault false
tagsRequired

tags applied to the subnet resource.

[string]: string
Map

Observed values

Outputs

Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.

subnetIdString
arnString
vpcIdString
cidrBlockString
availabilityZoneString
availabilityZoneIdString
mapPublicIpOnLaunchBoolean
stateString
ownerIdString
availableIpCountInteger

Read without ownership

Data-source lookup

A data block reads an existing Subnet and exposes its outputs without storing lifecycle state. The generic filter surface accepts id, name, and tag; supported combinations depend on the AWS identity used by this resource.

CUE data source
data: existing: {
  kind: "Subnet"
  region: "us-west-2"
  filter: {
    name: "replace-with-provider-name"
  }
}
Documented selectorsidnametag

Understand data sources and filters →

Adopt existing infrastructure

Import

Import persists Praxis state for an existing AWS resource. For this kind, supply: Subnet ID and region, for example subnet-0123456789abcdef0 in us-west-2. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import Subnet \
  --id <provider-identifier> \
  --region us-west-2 \
  --account production \
  --observe

Choose managed or observed ownership →

Canonical contract

Complete CUE schema

The field guide above is derived from this definition. The schema remains the source of truth for accepted values, defaults, validation constraints, and outputs in the current alpha revision.

Show the complete schema
schemas/aws/subnet/subnet.cue
package subnet

#Subnet: {
	apiVersion: "praxis.io/alpha"
	kind:       "Subnet"

	metadata: {
		name: string & =~"^[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}$"
		labels: [string]: string
	}

	spec: {
		// region is the AWS region for the subnet.
		region: string

		// vpcId is the VPC to create the subnet in.
		vpcId: string

		// cidrBlock is the IPv4 CIDR block for the subnet.
		cidrBlock: string & =~"^([0-9]{1,3}\\.){3}[0-9]{1,3}/([0-9]|[12][0-9]|3[0-2])$"

		// availabilityZone is the AZ to create the subnet in.
		availabilityZone: string

		// mapPublicIpOnLaunch controls whether instances launched in this subnet
		// receive a public IPv4 address by default.
		mapPublicIpOnLaunch: bool | *false

		// tags applied to the subnet resource.
		tags: [string]: string
	}

	outputs?: {
		subnetId:            string
		arn:                 string
		vpcId:               string
		cidrBlock:           string
		availabilityZone:    string
		availabilityZoneId:  string
		mapPublicIpOnLaunch: bool
		state:               string
		ownerId:             string
		availableIpCount:    int
	}
}

View this schema on GitHub →