aws-cdk-lib.aws_ec2.SubnetProps

interface SubnetProps

LanguageType name
.NETAmazon.CDK.AWS.EC2.SubnetProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#SubnetProps
Javasoftware.amazon.awscdk.services.ec2.SubnetProps
Pythonaws_cdk.aws_ec2.SubnetProps
TypeScript (source)aws-cdk-lib » aws_ec2 » SubnetProps

Specify configuration parameters for a VPC subnet.

Example

// 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
  mapPublicIpOnLaunch: false,
};

Properties

NameTypeDescription
availabilityZonestringThe availability zone for the subnet.
cidrBlockstringThe CIDR notation for this subnet.
vpcIdstringThe VPC which this subnet is part of.
mapPublicIpOnLaunch?booleanControls if a public IP is associated to an instance at launch.

availabilityZone

Type: string

The availability zone for the subnet.


cidrBlock

Type: string

The CIDR notation for this subnet.


vpcId

Type: string

The VPC which this subnet is part of.


mapPublicIpOnLaunch?

Type: boolean (optional, default: true in Subnet.Public, false in Subnet.Private or Subnet.Isolated.)

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