Skip to content

AWS::EC2::Subnet

Specifies a subnet for the specified VPC.

Generated by cfn-typegen --out cfn_types AWS::EC2::Subnet into cfn_types/ec2.py:

# Generated by cfn-typegen from the CloudFormation registry schemas. Do not edit.
# fmt: off
# ruff: noqa
"""AWS::EC2 resources."""

from collections.abc import Sequence
from typing import Any, Literal, NotRequired, Unpack
from typing_extensions import TypedDict
from cfn_typed.base import DeletionPolicy, DependsOn, ResourceAttrs, Tag, UpdateReplacePolicy, build
from cfn_typed.intrinsics import Expr


CONSTRAINTS:dict[str,Any]={
}


ATTRIBUTES:dict[str,Any]={"AWS::EC2::Subnet":["BlockPublicAccessStates","Ipv6CidrBlocks","NetworkAclAssociationId","SubnetId"]}


RULES:dict[str,Any]={}
Nested types (4)

These are defined above the properties in the generated module.

class SubnetPropsPrivateDnsNameOptionsOnLaunch(TypedDict, closed=True):
    'The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled.'
    HostnameType: NotRequired[Expr[str]]
    EnableResourceNameDnsARecord: NotRequired[Expr[bool]]
    EnableResourceNameDnsAAAARecord: NotRequired[Expr[bool]]


class SubnetProps(TypedDict, closed=True):
    'Specifies a subnet for the specified VPC.'
    AssignIpv6AddressOnCreation: NotRequired[Expr[bool]]
    'Indicates whether a network interface created in this subnet receives an IPv6 address.'
    VpcId: Expr[str]
    'The ID of the VPC the subnet is in.'
    MapPublicIpOnLaunch: NotRequired[Expr[bool]]
    'Indicates whether instances launched in this subnet receive a public IPv4 address.'
    EnableLniAtDeviceIndex: NotRequired[Expr[int]]
    'Indicates the device position for local network interfaces in this subnet.'
    AvailabilityZone: NotRequired[Expr[str]]
    'The Availability Zone of the subnet.'
    AvailabilityZoneId: NotRequired[Expr[str]]
    'The AZ ID of the subnet.'
    CidrBlock: NotRequired[Expr[str]]
    'The IPv4 CIDR block assigned to the subnet.'
    Ipv6CidrBlock: NotRequired[Expr[str]]
    'The IPv6 CIDR block.'
    OutpostArn: NotRequired[Expr[str]]
    'The Amazon Resource Name (ARN) of the Outpost.'
    Ipv6Native: NotRequired[Expr[bool]]
    'Indicates whether this is an IPv6 only subnet.'
    EnableDns64: NotRequired[Expr[bool]]
    'Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.'
    PrivateDnsNameOptionsOnLaunch: NotRequired[Expr[SubnetPropsPrivateDnsNameOptionsOnLaunch]]
    'The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled.'
    Tags: NotRequired[Expr[Sequence[Expr[Tag]]]]
    'Any tags assigned to the subnet.'
    Ipv4IpamPoolId: NotRequired[Expr[str]]
    'An IPv4 IPAM pool ID for the subnet.'
    Ipv4NetmaskLength: NotRequired[Expr[int]]
    'An IPv4 netmask length for the subnet.'
    Ipv6IpamPoolId: NotRequired[Expr[str]]
    'An IPv6 IPAM pool ID for the subnet.'
    Ipv6NetmaskLength: NotRequired[Expr[int]]
    'An IPv6 netmask length for the subnet.'


class Subnet(ResourceAttrs):
    'Specifies a subnet for the specified VPC.'
    Type: Literal['AWS::EC2::Subnet']
    Properties: SubnetProps


def subnet(
    *,
    depends_on: DependsOn | None = None,
    deletion_policy: DeletionPolicy | None = None,
    update_replace_policy: UpdateReplacePolicy | None = None,
    condition: str | None = None,
    metadata: dict[str, Any] | None = None,
    **props: Unpack[SubnetProps],
) -> Subnet:
    return build('AWS::EC2::Subnet', props, depends_on, deletion_policy, update_replace_policy, condition, metadata)

Attributes

Read-only values for get_att(logical_id, attribute). They are not accepted as inputs.

  • BlockPublicAccessStates
  • Ipv6CidrBlocks
  • NetworkAclAssociationId
  • SubnetId