Skip to main content

Subnet

A Subnet model is the logical sub-division of the region, e.g. a public and a private subnet. A subnet is often used to isolate parts of your infrastructure with access gates in the front.

  • A subnet can only belong to one region, but a region can have multiple subnets.
@example
const subnet = new Subnet(region, 'my-subnet');
subnet.subnetType = SubnetType.PUBLIC;
@group

Models/Subnet

@see

Definition of Default Models.

Hierarchy

Index

Constructors

constructor

  • Parameters

    • region: Region

      The region this subnet belongs to.

    • name: string

      The name of the subnet. The subnet's ID is derived from the region and this name.

    Returns Subnet

Properties

readonlyinheritedanchors

anchors: (MatchingAnchor<BaseAnchorSchema> | UnknownAnchor)[] = []

The anchors attached to this model, whether declared on it or borrowed from another model.

readonlysubnetId

subnetId: string

readonlysubnetName

subnetName: string

staticreadonlyinheritedNODE_NAME

NODE_NAME: string

The name of the node. All nodes with same name are of the same category.

staticreadonlyinheritedNODE_PACKAGE

NODE_PACKAGE: string

The package of the node.

staticreadonlyinheritedNODE_SCHEMA

NODE_SCHEMA: unknown

The schema of the node.

staticreadonlyinheritedNODE_TYPE

NODE_TYPE: NodeType

The type of the node.

Accessors

disableSubnetIntraNetwork

  • get disableSubnetIntraNetwork(): boolean
  • experimental

    To block/disable intra-network communication within self. When this is set to true, any execution within this subnet will not be able to communicate with other executions within the same subnet.

    @defaultValue

    false


    Returns boolean

subnetType

Methods

inheritedaddAnchor

  • To attach an AAnchor to this model. An anchor is only added once - re-adding the same anchor, identified by its ID and parent, throws.


    Parameters

    Returns void

inheritedgetAnchor

  • getAnchor(anchorId: string, parent?: UnknownModel): UnknownAnchor | undefined
  • To get an attached anchor by its ID.


    Parameters

    • anchorId: string

      The ID of the anchor.

    • optionalparent: UnknownModel

      The model that declared the anchor. Defaults to self.

    Returns UnknownAnchor | undefined

inheritedgetAnchorIndex

  • getAnchorIndex(anchorId: string, parent?: UnknownModel): number
  • The position of an attached anchor in AModel.anchors, or -1 when it is not attached.


    Parameters

    • anchorId: string

      The ID of the anchor.

    • optionalparent: UnknownModel

      The model that declared the anchor. Defaults to self.

    Returns number

inheritedgetAnchors

  • To get all attached anchors, narrowed by anchor class and/or by the value of their properties.


    Parameters

    • filters: { key: string; value: unknown }[] = []

      Each filter is a property key the anchor must carry with the given value.

    • types: Constructable<MatchingAnchor<BaseAnchorSchema> | UnknownAnchor>[] = []

      The anchor classes to keep. An empty list keeps every class.

    Returns UnknownAnchor[]

inheritedgetAnchorsMatchingSchema

  • getAnchorsMatchingSchema<S>(from: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingAnchor<S>[]>
  • To find anchors by their schema rather than by their class.

    This is how a module consumes what another module produced without importing its classes - you match on the shape you need, and any anchor satisfying that shape is returned. Anchors that do not satisfy the schema are skipped, not reported as errors.

    @see

    Definition of Anchors.


    Type parameters

    Parameters

    • from: Constructable<S>

      The anchor schema to match against.

    • propertyFilters: ObjectKeyValue<S[properties]>[] = []

      Each filter is a property key the anchor must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingAnchor<S>[]>

inheritedgetModelsMatchingSchema

  • getModelsMatchingSchema<S>(schema: Constructable<S>, filters?: ObjectKeyValue<S>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingModel<S>[]>
  • To find models by their schema. See AModel.getAnchorsMatchingSchema.


    Type parameters

    • S: object

    Parameters

    • schema: Constructable<S>

      The model schema to match against.

    • filters: ObjectKeyValue<S>[] = []

      Each filter is a schema key the model must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingModel<S>[]>

inheritedgetOverlaysMatchingSchema

  • getOverlaysMatchingSchema<S>(schema: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingModel<S>[]>
  • To find overlays by their schema. See AModel.getAnchorsMatchingSchema.


    Type parameters

    Parameters

    • schema: Constructable<S>

      The overlay schema to match against.

    • propertyFilters: ObjectKeyValue<S[properties]>[] = []

      Each filter is a property key the overlay must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingModel<S>[]>

inheritedgetResourcesMatchingSchema

  • getResourcesMatchingSchema<S>(schema: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], responseFilters?: ObjectKeyValue<S[response]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingResource<S>[]>
  • To find resources by their schema. See AModel.getAnchorsMatchingSchema.

    Only resources produced by the modules that own the searched models are considered, so this returns another module's resources rather than every resource in the run.


    Type parameters

    Parameters

    • schema: Constructable<S>

      The resource schema to match against.

    • propertyFilters: ObjectKeyValue<S[properties]>[] = []

      Each filter is a property key the resource must carry with the given value.

    • responseFilters: ObjectKeyValue<S[response]>[] = []

      Each filter is a response key the resource must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingResource<S>[]>

inheritedremoveAllAnchors

  • removeAllAnchors(): void
  • To detach every anchor from this model.


    Returns void

inheritedremoveAnchor

  • To detach an anchor from this model. Detaching an anchor that is not attached is a no-op.


    Parameters

    Returns void

updateNetworkingRules

  • updateNetworkingRules(subnet: Subnet, allowConnections: boolean): void
  • To update the networking rules of this subnet to allow or deny connectivity from another subnet. The networking rules are uni-directional, i.e. if subnet A can connect to subnet B, then subnet B doesn't automatically connect to subnet A.


    Parameters

    • subnet: Subnet

      The other subnet.

    • allowConnections: boolean

      Set to true to allow this and the other subnet to connect. Set to false to block this and the other subnet from connecting.

    Returns void