SubnetV2Props

class aws_cdk.aws_ec2_alpha.SubnetV2Props(*, availability_zone, ipv4_cidr_block, subnet_type, vpc, assign_ipv6_address_on_creation=None, ipv6_cidr_block=None, route_table=None, subnet_name=None)

Bases: object

(experimental) Properties to define subnet for VPC.

Parameters:
  • availability_zone (str) – (experimental) Custom AZ for the subnet.

  • ipv4_cidr_block (IpCidr) – (experimental) ipv4 cidr to assign to this subnet. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-cidrblock

  • subnet_type (SubnetType) – (experimental) The type of Subnet to configure. The Subnet type will control the ability to route and connect to the Internet. TODO: Add validation check subnetType when adding resources (e.g. cannot add NatGateway to private)

  • vpc (IVpcV2) – (experimental) VPC Prop.

  • assign_ipv6_address_on_creation (Optional[bool]) – (experimental) Indicates whether a network interface created in this subnet receives an IPv6 address. If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock. Default: - undefined in case not provided as an input

  • ipv6_cidr_block (Optional[IpCidr]) – (experimental) Ipv6 CIDR Range for subnet. Default: - No Ipv6 address

  • route_table (Optional[IRouteTable]) – (experimental) Custom Route for subnet. Default: - a default route table created

  • subnet_name (Optional[str]) – (experimental) Subnet name. Default: - provisioned with an autogenerated name by CDK

Stability:

experimental

ExampleMetadata:

infused

Example:

my_vpc = VpcV2(self, "Vpc")
route_table = RouteTable(self, "RouteTable",
    vpc=my_vpc
)
subnet = SubnetV2(self, "Subnet",
    vpc=my_vpc,
    availability_zone="eu-west-2a",
    ipv4_cidr_block=IpCidr("10.0.0.0/24"),
    subnet_type=SubnetType.PRIVATE_ISOLATED
)

natgw = NatGateway(self, "NatGW",
    subnet=subnet,
    vpc=my_vpc,
    connectivity_type=NatConnectivityType.PRIVATE,
    private_ip_address="10.0.0.42"
)
Route(self, "NatGwRoute",
    route_table=route_table,
    destination="0.0.0.0/0",
    target={"gateway": natgw}
)

Attributes

assign_ipv6_address_on_creation

(experimental) Indicates whether a network interface created in this subnet receives an IPv6 address.

If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

Default:
  • undefined in case not provided as an input

Stability:

experimental

availability_zone

(experimental) Custom AZ for the subnet.

Stability:

experimental

ipv4_cidr_block

(experimental) ipv4 cidr to assign to this subnet.

See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-cidrblock

Stability:

experimental

ipv6_cidr_block

(experimental) Ipv6 CIDR Range for subnet.

Default:
  • No Ipv6 address

Stability:

experimental

route_table

(experimental) Custom Route for subnet.

Default:
  • a default route table created

Stability:

experimental

subnet_name

(experimental) Subnet name.

Default:
  • provisioned with an autogenerated name by CDK

Stability:

experimental

subnet_type

(experimental) The type of Subnet to configure.

The Subnet type will control the ability to route and connect to the Internet.

TODO: Add validation check subnetType when adding resources (e.g. cannot add NatGateway to private)

Stability:

experimental

vpc

(experimental) VPC Prop.

Stability:

experimental