Skip to content
v2.273.0

SubnetProps Struct ​

Specify configuration parameters for a VPC subnet.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const subnetProps: ec2.SubnetProps = {
  availabilityZone: 'availabilityZone',
  cidrBlock: 'cidrBlock',
  vpcId: 'vpcId',

  // the properties below are optional
  assignIpv6AddressOnCreation: false,
  ipv6CidrBlock: 'ipv6CidrBlock',
  mapPublicIpOnLaunch: false,
};

Properties ​

assignIpv6AddressOnCreationbooleanassign_ipv6_address_on_creationboolassignIpv6AddressOnCreationBooleanAssignIpv6AddressOnCreationboolAssignIpv6AddressOnCreation*bool= false#
Indicates whether a network interface created in this subnet receives an IPv6 address.

If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

availabilityZonestringavailability_zonestravailabilityZoneStringAvailabilityZonestringAvailabilityZone*stringrequired#
The availability zone for the subnet.
cidrBlockstringcidr_blockstrcidrBlockStringCidrBlockstringCidrBlock*stringrequired#
The CIDR notation for this subnet.
ipv6CidrBlockstringipv6_cidr_blockstripv6CidrBlockStringIpv6CidrBlockstringIpv6CidrBlock*string= no IPv6 CIDR block.#
The IPv6 CIDR block.

If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

mapPublicIpOnLaunchbooleanmap_public_ip_on_launchboolmapPublicIpOnLaunchBooleanMapPublicIpOnLaunchboolMapPublicIpOnLaunch*bool= true in Subnet.Public, false in …#
Controls if a public IP is associated to an instance at launch.
default

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

vpcIdstringvpc_idstrvpcIdStringVpcIdstringVpcId*stringrequired#
The VPC which this subnet is part of.

Used as props by ​