Skip to main content

AwsSimpleSubnetModule

AwsSimpleSubnetModule creates a VPC subnet in one availability zone (subnetCidrBlock, subnetAvailabilityZone) with an optional NAT gateway (subnetOptions.createNatGateway) and EFS filesystems mounted (localFilesystems).

@cost

A subnet, its route table and its network ACL are free. A NAT gateway (subnetOptions.createNatGateway) bills about $0.045 an hour (about $32 a month) plus about $0.045 per GB it carries, and its public IPv4 address about $0.005 an hour, in us-east-1.

@downtime

A replaced subnet takes what runs in it down with it until it is created again. A replaced NAT gateway cuts the outbound internet of every subnet routed through it until its successor is up.

@example

TypeScript

import { type Filesystem, type Region, type Subnet, SubnetType, stub } from '@quadnix/octo';
import { AwsSimpleSubnetModule } from '@quadnix/octo-aws-cdk/modules/subnet/aws-simple-subnet';

octo.loadModule(AwsSimpleSubnetModule, 'my-subnet-module', {
localFilesystems: [stub<Filesystem>('${{my-filesystem-module.model.filesystem}}')],
region: stub<Region>('${{my-region-module.model.region}}'),
subnetAvailabilityZone: 'us-east-1a',
subnetCidrBlock: '10.0.1.0/24',
subnetName: 'private-subnet-1',
subnetOptions: {
createNatGateway: false,
disableSubnetIntraNetwork: false,
subnetType: SubnetType.PRIVATE,
},
subnetSiblings: [{
attachToNatGateway: true,
subnet: stub<Subnet>('${{my-sibling-subnet-module.model.subnet}}'),
}],
});
@group

Modules/Subnet/AwsSimpleSubnet

@limit

A private subnet reaches the internet only through a sibling's NAT gateway (subnetSiblings with attachToNatGateway). AWS keeps five addresses of every subnet for itself.

@limit

subnetCidrBlock lies inside the region's vpcCidrBlock and overlaps no other subnet; subnetAvailabilityZone is one of the region's zones.

@limit

A mounted EFS filesystem accepts NFS traffic (port 2049) from this subnet's subnetCidrBlock only.

@limit

A public subnet's network ACL allows all traffic in and out, so only security groups filter it.

@limit

A NAT gateway is a public one whose Elastic IP AWS allocates: an address of your own cannot be assigned.

@losesData

Nothing of its own: a subnet holds no data. Replacing it replaces what lies inside, and that loses whatever those modules' losesData names.

@replaces

Changing subnetCidrBlock, subnetAvailabilityZone or subnetName replaces the subnet and everything in it.

@see

Hierarchy

Index

Constructors

constructor

  • Parameters

    • moduleId: string

      The ID this module is loaded under.

    Returns AwsSimpleSubnetModule

Properties

readonlyinheritedmoduleId

moduleId: string

The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.

staticreadonlyinheritedMODULE_PACKAGE

MODULE_PACKAGE: string

The package the module is registered under, set by Module.

staticreadonlyinheritedMODULE_SCHEMA

MODULE_SCHEMA: any

The schema of the module's inputs, set by Module.

Methods

onInit

  • Validates the availability zone and CIDR against the region, creates the subnet, wires its sibling rules, and overlays any filesystem mounts.


    Parameters

    Returns Promise<(AwsSimpleSubnet | AwsSimpleSubnetLocalFilesystemMountOverlay)[]>

inheritedregisterHooks

  • registerHooks(): { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
  • To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.

    @see

    Techniques for Hooks.


    Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }

    • optionalpostCommitHooks?: PostHookSignature[]
    • optionalpostModelActionHooks?: PostHookSignature[]
    • optionalpostResourceActionHooks?: PostHookSignature[]
    • optionalpreCommitHooks?: PreHookSignature[]
    • optionalpreModelActionHooks?: PreHookSignature[]
    • optionalpreResourceActionHooks?: PreHookSignature[]

registerMetadata

  • registerMetadata(inputs: AwsSimpleSubnetModuleSchema): Promise<{ awsAccountId: string; awsAvailabilityZones: string[]; awsRegionId: string; awsRegionVpcCidrBlock: string }>
  • Resolves the account, region, the region's availability zones, and its VPC CIDR block.


    Parameters

    Returns Promise<{ awsAccountId: string; awsAvailabilityZones: string[]; awsRegionId: string; awsRegionVpcCidrBlock: string }>