AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

Subnet

Represents a new VPC subnet resource.

Import

import { Subnet } from 'aws-cdk-lib/aws-ec2';

Or use the module namespace:

import * as ec2 from 'aws-cdk-lib/aws-ec2';
// ec2.Subnet

Properties

Configuration passed to the constructor as SubnetProps.

availabilityZoneRequired
string

The availability zone for the subnet.

cidrBlockRequired
string

The CIDR notation for this subnet.

vpcIdRequired
string

The VPC which this subnet is part of.

assignIpv6AddressOnCreationOptional
boolean

Indicates whether a network interface created in this subnet receives an IPv6 address. If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

Default: false

ipv6CidrBlockOptional
string

The IPv6 CIDR block. If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

Default: - no IPv6 CIDR block.

mapPublicIpOnLaunchOptional
boolean

Controls if a public IP is associated to an instance at launch.

Default: true in Subnet.Public, false in Subnet.Private or Subnet.Isolated.

Get the Amazon EC2 Cheat Sheet

Everything you need to know about Amazon EC2 on one page. HD quality, print-friendly.

Download Free Infographic